-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
websocket options #1040
Comments
any traction on this? |
Sorry, I haven't had a chance to look into this yet, I have a few other admin things I want to get to first. Is the problem it disconnects after a short time? You may be able to use |
thanks for the response. Do you important stuff, just been going back and forth with infura trying to track down why one service loses connection, and the other doesn't. Both are connecting the same with ethers via websocket. My first attempt at a fix was the above, I too thought that might work. Infura recommends adding a keep-alive ping. I am still not sure what the issue here is, but I was curious if there was a comparable options. thanks |
My gas-ticker stays connected for hours at a time, but I do use that |
I will look into this, thank you. And I do need to write some reconciliation script to re-connect if it gets severed. I'll take a look, thanks again. |
@tobyjaguar you can use the web3-providers-ws package and pass it in as a Web3Provider to ethers |
Interesting. I ended up writing a heartbeat function into my process as there are many reconnects with infura. But this looks promising as a more permanent solution. Would need to resubscribe to events on reconnect. I will look into it. Thank you. |
yeah you can probably submit a pr to the web3-providers-ws package that auto subscribes on reconnect! |
@tobyjaguar can you share your heartbeat function? I'm on the same boat, looking to re-connect ethers.js web socket in case the connection is dropped. Thanks! |
I never explored @rymnc 's suggestion regarding the options of the web3-providers-ws package:
That is probably a better way to go, but I had already attempted a heartbeat process. After tinkering with it for a couple weeks this seems to work for my purposes. It is probably a bit overkill, but I grab a beat tolerance from config, register a timestamp and then just continuously consume the heartbeat function().
The above has kept my processes online since I implemented the above. Things go horribly wrong if the process loses the internet connection, but it can heal a lost connection with infura, which seems to happen all the time. |
I think it would be best if someone extended the websocket provider/made a pr on the existing one which handles websocket reconnections + resubscriptions etc! |
alright, my band-aid solution doesn't work so well on L2 as those blocks are inconsistent. This is how I am currently connecting to L2, until infura catches up. |
@smartins don't know if you ever got a keepalive function going, but I have had success with this design: thanks to @mikevercoelen for posting |
@tobyjaguar I also face this kind of problem, Can you post your code |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Infura is telling me that I should ping the connection to keep it alive for websockets. They suggested using this options in web3:
https://web3js.readthedocs.io/en/v1.2.11/web3.html#providers
Is there comparable options in ethers that I can take advantage of?
The text was updated successfully, but these errors were encountered: