-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Reconnect on Websocket Drop #1558
Comments
I've been having this issue as well. Is there any sort of EDIT:
There is also an on('connect', ...) and an on('error', ...) function as well, both also return event objects. I still don't know the best way to reconnect the websocket, and it still keeps randomly disconnecting every now and then (the websocket timeout option doesn't work at all) and I don't think there is a 'keep-alive' message thing. But hopefully using the .on('end', ...) helps you catch a socket when it does drop @Plinpod |
I am also facing the same issue.I use websocket (ws) coneection to Infura node
sometimes it's works fine or sometimes it give error on console :
|
Also having this issue. Handling connection in errors using |
Does anyone have a working solution via polling web3.eth.net.isListening()? |
Hello,
I am making a websocket connection to Infura Ropsten
wss://ropsten.infura.io/ws
and then making contract event subscription like so
contract.events.MyEvent() .on('data', function(event) { console.log('Event Generated', data) }) .on('error', function(error) { console.log('Event Error', error) })
Infuras websockets seem to be unstable and drop randomly. Unfortunately the websocket drops silently in the background and my event never receives the error. My app just continues to work and stops receiving event data.
I can tell that websocket drops by running
setInterval
onweb3.eth.net.isListening()
Is there a graceful way to catch the websocket drop and reconnect immediately? If not what is a safe interval to run isListening on?
Thanks!
The text was updated successfully, but these errors were encountered: