ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

Websocket `onclose` event not enabled

Open valeriivanchev opened this issue 1 year ago • 7 comments

Ethers Version

6.8.1

Search Terms

No response

Describe the Problem

Infura closes the idle websocket connections and we want to reconnect after that. The problem is that in the WebSocketProvider implementation of ethers the onclose handler is commented out and not a part of the WebSocketLike interface. To fix this issue we need to do a workaround. Can you enable onclose handler or is it planned an actual reconnect implementation out of the box?

Code Snippet

No response

Contract ABI

No response

Errors

No response

Environment

No response

Environment (Other)

No response

valeriivanchev avatar Feb 09 '24 08:02 valeriivanchev

It is planned (in the next minor release) to automatically reconnect, resubscribe and backfill events.

In the meantime though, you can add the listeners to the WebSocket before passing it to the WebSocketProvider. The limitations on the wrapped socket are intentional so other socket-like things can be done with minimal implementations.

I’ll update this issue as the resubscribe is implemented.

ricmoo avatar Feb 09 '24 09:02 ricmoo

Perfect thanks for the quick update. Just one more question when is the next minor release?

valeriivanchev avatar Feb 09 '24 13:02 valeriivanchev

Hi @ricmoo is there an update regarding the issue?

valeriivanchev avatar Mar 11 '24 13:03 valeriivanchev

Hello, any news on this?

Linch1 avatar Mar 28 '24 20:03 Linch1

@ricmoo when is this update done?

danielmedvec avatar Apr 30 '24 13:04 danielmedvec

@ricmoo Could you give an update regarding this issue?

valeriivanchev avatar May 20 '24 13:05 valeriivanchev