Re: [Server-Sent Events] Infinite reconnection clarification

On Tue, Jun 12, 2012 at 6:30 PM, Pablo Flouret <> wrote:

> This spec problem can be worked around by observing the error event. If
> the readyState property is now CLOSED (in readyState 2), we set a 30 second
> timeout. When this fires, we create a new eventsource object to replace the
> old one (you can’t reuse them) which will then try connecting again;
> essentially this is manually recreating the reconnect behaviour."

This is exactly the sort of bad workaround that I was talking about.  It
causes at least two problems.  First, user annoyance at having to wait 30
seconds for it to reconnect (if it takes 2 seconds to reestablish the
connection, the browser can know this and reconnect promptly instead of
making the user twiddle his thumbs for half a minute).  Second, if the
server dumps every connection simultaneously (eg. the server process
crashed) then every client will be on the same 30-second timer, resulting
in every client periodically hammering the server simultaneously.  A smart
client implementation can avoid this, randomizing the delay so the
reconnects come in at different times, but you can't expect every web
developer to implement that.

Glenn Maynard

Received on Wednesday, 13 June 2012 13:36:31 UTC