automerge / automerge-repo

MIT License
419 stars 43 forks source link

WebSocket client disconnection #324

Open mweidner037 opened 3 months ago

mweidner037 commented 3 months ago

For testing purposes (especially testing concurrent operations), it would be convenient if I could programmatically disconnect and reconnect a BrowserWebSocketClientAdapter - as if the connection dropped.

I tried calling disconnect() on the adapter, but it does not actually close the socket, just let the server know that we are leaving. So the local repo continues syncing with other peers.

nikgraf commented 2 days ago

If you store the browserWebSocketClientAdapter separately you can call browserWebSocketClientAdapter.socket?.close();. That said currently automerge-repo will continue trying to reconnect based on the retryInterval

Would be great to completely close a socket.

My use-case is: a user logs out of the application and everything should be closed