-
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
WebSocketProvider is not reconnecting to node after the connection is lost #7351
Comments
@yanosh1982 hey there, can you join the web3.js chainsafe discord. i'll try to help there https://discord.gg/3KvND4Cx |
Edit: it seems to be provider dependent. I was able to get an error with closing geth. will keep you updated. thanks for reporting this |
Hey I was able to recreate your issue, where it connects but it seems to lose the subscription. |
Hey @luu-alex, thank you for your suggestion. This hasn't solved my problem. If i restart the node the events listening stops. My node is a hyperledger besu node and the network is a private proof of authority network I think the whole problem depends on my application lifecycle. According to my needs i perform the connection onApplicationBootstrap that is fired, obviously, one time. My thought was that setting autoReconnect=true, the provider would ping the node to check the connection, performing a re-connection if it was lost. Check my code after importing your snippet
If the node restarts, the application is bootstrapped and onApplicationBootstrap is not executed. The question is: the provider is still pinging the node and, in case, tries to reconnect to it? |
will take a look into it |
Update: I was able to confirm that it seems to be a hyperledger/besu issue with web3.js while other providers work when node restarts. ill continue seeing how i can fix this |
Hey there, heres an update with an extra listener With most providers when they are terminated they send an error but with besu they emit a disconnect. so we just need to cover that case
So in all, add this and it should work
|
Hey @luu-alex. I've tried your suggestion. This is my code now
When I stop the node, the disconnect event is fired and resubscribeToEthNewBlockHeaders function is called, but then I get an error when executing
this is the complete function
Can't understand why the error is not caught in the catch block |
ya not sure why too, this works on my end |
Let me know if u face any other issues, thanks for reporting this |
Hi, after this issue has been closed I've tried to set up a connection with WebSocketProvider on a node with reconnecting options, but the client is not reconnecting when the connection is lost. This is the snippet on how I am establishing the connection
this is the output
If I turn of wi-fi, or stop and restart the node, the application simply stops logging without reconnecting.
Notice I'm using version 4.14.0 as shown in my package-lock.json
Thank you
The text was updated successfully, but these errors were encountered: