Sometimes, people get disconnected from the live update server. Bugs, flaky Internet connection, maintenance, it happens.

I find the live updates quite useful for keeping track of new posts, but sometimes I get disconnected and I won't have any idea it happened. Could be hours before I notice the lack of activity, because sometimes, there really isn't any.

Could we get a visual indicator that tells us whether live updates are active on the current page? Here's two ideas:

  • a symbol in the header somewhere that changes depending on live connectivity

  • showing (?) in the title bar if the connection was dropped (not if it failed initially, no point in having it on every tab if that particular server is down)


2 Answers 2


This suggestion is good, but not trivial to implement. I'm using the given WebSocket feature to generate real-time desktop notifications, and also encountered the issue you've mentioned.

Although my application is slightly different (I want to make sure that the connection always exists, you want to show a notification when something happens), the techniques are similar.

Chrome supports the online / offline events. On online, I'm resetting the socket connection: source code.
Firefox's online/offline events are useless, because these only fire when the user manually selects the "Work offline" option in the menu...

Alternative method
Currently, the backend broadcasts a "hb" message every 5 minutes. This characteristic can be utilized by checking whether the connection is stable or not with setInterval (source code).

  1. ws.onopen event - Store Date.now() in a variable, say lastHeartbeat, and start watching the connection using setInterval.
    In the watcher, check if the difference between Date.now() and lastHeartbeat is exceeds a certain value (at least >300 because the heartbeat runs every ~ 5 minutes).
  2. ws.onmessage event with message "hb" - Update lastHeartbeat with Date.now()

The disadvantage of the last method is that it's not known immediately whether or not the connection died. So, if you unplug your cable for a minute, and a message comes in during this minute, you won't get notified of it.

  • PS. If anyone knows a reliable method to detect network connection in Firefox, please share. It's going to be used in a Firefox add-on, so NPAPI plugins are also alright (provided that the source code / clear documentation is available). I think that I've found the relevant commit in Chromium's source code, but I don't know how to use it: bugs.webkit.org/attachment.cgi?id=161672&action=prettypatch
    – Rob W
    Commented Dec 13, 2012 at 11:16
  • 5 minutes seems to be too long - I'd be interested to see how much bandwidth would be required to send a ping/pong every 30 seconds or so
    – Swadq
    Commented Dec 13, 2012 at 19:28
  • @Swadq The high-level ping/pong interval of 5 minutes is already implemented. I'm not proposing any changes to the API, but rather providing some details about the implementation of the requested feature.
    – Rob W
    Commented Dec 13, 2012 at 19:50

Yes, please!

This would be very useful. Especially for users living in an area with terrible internet connectivity, where the connection gets lost all the time.

I use the live updates to observe my favorite tags on Stack Overflow and it would be very useful to see if live updates are still delivered or not.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .