rust-web3
rust-web3 copied to clipboard
Add `WebSockets: Reconnecting`
Hello.
When I use websocket transport for a period, it will report WS connection error: Closed
error.
And I see that there is a feature WebSockets: Reconnecting & Pings
in the doc which has not realized until now.
Is there any plan for it?
Thanks.
I'd like to add reconnection for websockets, but I just think of one case:
- swap
sender
andreceiver
with the new ones when the previous connection is closed and notice to not fuse streams.
Is there any other cases I should handle? Thanks for any guides.
In my opinion, there should be three steps to do with connection error:
- Remove all pending request and send connection error back.
- Remove all subscriptions and send connection error back.
- Swap websockets handshake with a new one, if cannot get a valid handshake, do nothing until next request and then reconnect.
Any guides? @tomusdrw
I see https://github.com/ethers-io/ethers.js/issues/1053 using interval pings. But I think there may be some custom logic to do if a connection error happened.