Is there any way to catch when this appears in the console:
WebSocket connection to 'wss://myserver.com/' failed: The operation couldn’t be completed. Connection reset by peer
And I don’t mean at startup: I mean when the thing has been running for a while and then something happens (mainly a network connection is lost).
Basically I want to be able to detect when the connection is lost. I don’t see a way to register an event handler for disconnection, and I’ve tried a couple of more elaborate schemes on my end but they’re a little brittle.
wsProvider.on('status', function({ status: 'disconnected' | 'connecting' | 'connected' }))
Receive updates about the current connection status.
wsProvider.on('connection-close', function(WSClosedEvent))
Fires when the underlying websocket connection is closed. It forwards the websocket event to this event handler.
wsProvider.on('connection-error', function(WSErrorEvent))
Fires when the underlying websocket connection closes with an error. It forwards the websocket event to this event handler.