We’re trying to use pushpin in order to support websockets in our application.
We’ve configured pushpin to route websockets messages to our backend over http.
Our backend is written in Django and using the examples provided, we were able to accept websockets connections and send/receive messages.
We built a simple HTML page to test the websocket connections.
We’re receiving a “CLOSE” event in the backend when the page is closed in the browser.
However, when we tested network loss, there is no event received on the backend side. Sometimes we receive the “DISCONNECT” event on the backend side, but it only happens after a long wait (e.g. 15 min).
We need to detect user disconnects (by closing browser tab or network loss) in real time.
Can pushpin do that? Do we need to change some kind of configuration in order to support it?
When a client disconnects, most of the time your backend will get a CLOSE/DISCONNECT event immediately. However, as you’ve noticed, sometimes this doesn’t work, for example when there’s network loss.
As a fallback, we recommend having clients send heartbeats. This way your backend has a guaranteed way to detect client absence, in case it never receives a CLOSE/DISCONNECT event. For example, clients could send a message every 30 seconds, and if the backend has not received an event from a client in 45 seconds then the client could be considered gone.