Error Message: Net::ReadTimeout

I’m running a Python script that’s sleeps for a while then sends a bunch of queries one after the other, before sleeping and repeating again. This is a new project but the query is one I ripped from another project and it’s been working fine. For some reason I keep getting the following error message on the first query, then the next ones are fine. The only difference between the various queries is the contract address, the code is exactly the same. I pulled the query out and dropped it into the IDE and it worked without issue.

{‘data’: {‘ethereum’: {‘dexTrades’: None}}, ‘errors’: [{‘message’: ‘Net::ReadTimeout with #TCPSocket:(closed)’, ‘locations’: [{‘line’: 5, ‘column’: 13}], ‘path’: [‘ethereum’, ‘dexTrades’], ‘error_type’: ‘client’}]}

Anyone got any ideas?

So I checked it again and I had a different error message. This one said something about it taking 35 seconds to complete the query, so I’m thinking I’m accidentally pulling too many transactions. I just need a quick and dirty way of getting the latest price but this particular query is for BNB to USDT. I have a limit option thing set to 1 but does that mean it’s just filtering it to one result after fetching every result ever?

Here’s my query:

{
ethereum(network: bsc) {

    dexTrades(
    options: {desc: ["block.height", "tradeIndex"], limit: 1}
    exchangeName: {in: ["Pancake", "Pancake v2"]}
    baseCurrency: {is: **BNB HERE**}
    quoteCurrency: {is: **USDT HERE**}
    ) {
    smartContract {
        address {
        address
        }
        currency {
        name
        }
    }
    date {
        date
    }
    buyCurrency {
        address
    }
    sellCurrency {
        symbol
    }
    tradeAmount(in: USD)
    block {
        height
    }
    quotePrice
    block {
        height, timestamp {time(format: "%Y-%m-%d %H:%M:%S")}
    }
    tradeIndex
    }
}

}

Do I need to add something to limit it to a certain date window or is there another way of limiting it to one result? Is that what’s wrong?

Please provide the complete query with the address as well, so we can optimize it

Thanks for getting back. I’ll post everything when I get home.

So I’ve just run it again and this is what happened starting with the query:

{
ethereum(network: bsc) {

        dexTrades(
        options: {desc: ["block.height", "tradeIndex"], limit: 1}
        exchangeName: {in: ["Pancake", "Pancake v2"]}
        baseCurrency: {is: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"}
        quoteCurrency: {is: "0x55d398326f99059ff775485246999027b3197955"}
        ) {
        smartContract {
            address {
            address
            }
            currency {
            name
            }
        }
        date {
            date
        }
        buyCurrency {
            address
        }
        sellCurrency {
            symbol
        }
        tradeAmount(in: USD)
        block {
            height
        }
        quotePrice
        block {
            height, timestamp {time(format: "%Y-%m-%d %H:%M:%S")}
        }
        tradeIndex
        }
    }
}

And this is the result:

{‘data’: {‘ethereum’: {‘dexTrades’: None}}, ‘errors’: [{‘message’: ‘ActiveRecord::ActiveRecordError: Response code: 500:\nCode: 241, e.displayText() = DB::Exception: Memory limit (total) exceeded: would use 113.11 GiB (attempt to allocate chunk of 9600528 bytes), maximum: 113.10 GiB: While executing AggregatingTransform (version 20.8.11.17 (official build))\n’, ‘locations’: [{‘line’: 5, ‘column’: 13}], ‘path’: [‘ethereum’, ‘dexTrades’], ‘error_type’: ‘server’}]}

Okay, I’ve solved it I think.

I added time: {after: “2022-03-25T19:18:48.666773”}

to the line after quoteCurrency under dexTrades. I thought that limit: 1 would make it only bring in the last result but I guess it was pulling them all then filtering the output.