1

I am using JsonRpcProvider in ethers V6. I am sending requests to node like getBlocknumber, getBalance ,sendTransaction etc through JsonRpcProvider. I want to set the response timeout for the requests I send to the node through the provider.

I have found and tried many methods but all of them failed. Doing it in ethers V5 and V6 is also fine. can you please advise me.

1 Answer 1

1

There is timeout parameter in ConnectionInfo object. According to https://docs.ethers.org/v5/api/utils/web/#ConnectionInfo

Have You tried manipulating it?

const provider = new JsonRpcProvider(rpcUrl);

provider._getConnection().timeout = 600;

Since requests are then send using this _getConnection() response object. Default is 5 minutes.

2
  • I already tried this method: I set the timeout to 10 (milliseconds) and tested it by calling provider.getBlocknumber(). I expected to get a timeout error, but it worked fine. This method did not solve the problem
    – imelon2
    Sep 25 at 11:04
  • I try it again on ethers V5. Your method seems to work fine for timeout in V5, but not in V6..
    – imelon2
    Sep 25 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.