3 ms·
> Disconnects are difficult to detect as well I am using the npm module rexxars/sse-channel. Maintaining connection has worked very well. During debugging I
by mchahn 11y ago
> Disconnects are difficult to detect as well
I am using the npm module rexxars/sse-channel. Maintaining connection has worked very well. During debugging I reload the server and/or client repeatedly and things just stay connected. I'm not sure if this is due to the way chrome handles the connection or the quality of the npm module.
- geocar 11y agoI have not looked at rexxars/sse-channel. If you disconnect the client and the client is behind some firewalls (or in some other circumstances), the server might not get notified until it writes something, but the client will reconnect automatically. This means that the server now has two connections, and to handle the error-on-write. If the server periodically writes something, then it will get the error and can recover. If the server does not (however) it will eventually run out of connections. However another approach is to simply set the socket timeout (SO_RCVTIMEO) every time you write. This disconnects the socket automatically, and the client will (if still around) will reconnect. The savings can be significant on a busy server.
- mchahn 11y agorexxars/sse-channel has a very useful support of history. When a client is disconnected and then reconnected, events that were missed are automatically resent. They use the ID provided by SSE to know what to send. You can count on all events getting through without a lot of overhead. One thing I think is wrong though is that no ID is sent on the first connection so history isn't sent then. My app needs this so I send the history myself on new connections.