Improve websocket reliability: reconnect on close + keep alive #2101
Replies: 3 comments 2 replies
-
That’s a good idea! |
Beta Was this translation helpful? Give feedback.
-
@jxom I think we should differ between external close (server sends close) vs user closes socket. In the case in which the user closes the sockets no reconnect should be attempted. Also what do you think about using the same |
Beta Was this translation helpful? Give feedback.
-
I mentioned this before on other chat, but polkadot.js/api library has a pretty good WebsocketProvider with both keepalive and reconnect mechanism. The code obviously doesn't fit ethereum json rpc api spec, but as a high level implementation examples I think it's good. You can see the code here: https://github.com/polkadot-js/api/tree/d65074498478c509a0a9722cc288f3d16ae38f9d/packages/rpc-provider/src/ws |
Beta Was this translation helpful? Give feedback.
-
As of #2073 we have reconnect functionality on error which is great! I am missing a similar feature for closing connections. For instance I am dealing with a node provider which may arbitrarily close the connection at any time. This is not being handled by #2073. I would love to see a (perhaps optional?) reconnect function for closing connections.
EDIT: I would like to see the the general state of websocket reliability to improve. For instance not only will any subscriptions run stale when the websockets are closed (or even when error occurs) but also a native keep alive for websockets is currently not supportd. Imo those are very important features.
Beta Was this translation helpful? Give feedback.
All reactions