title: SSE (server sent events) disconnections
body: <p>I'm trying to use SSE (in chrome) for a ticker application.
  It seems that in every sample I found or wrote the connection is closed every 3-4 seconds.
  Even when running the example at :
  <a href="http://www.w3schools.com/html5/tryit.asp?filename=tryhtml5_sse" rel="nofollow">http://www.w3schools.com/html5/tryit.asp?filename=tryhtml5_sse</a></p>
  
  <p>you can see that an update arrives every 3-4 seconds. This is not due to the server 
  implementation ("demo_sse.php" in this example), but due to a reconnect which occurs every 3-4 seconds.</p>
  
  <p>If I add the following to the above example:</p>
  
  <pre><code>source.onerror=function(event)
  {
    document.getElementById("result").innerHTML+=source.readyState+ "&lt;br /&gt;";
  };
  </code></pre>
  
  <p>you can clearly see that the readyState is 0, meaning : "The connection has not yet been established, or it was closed and the user agent is reconnecting." (taken from the official EventSorce API doc).</p>
  
  <p>I wrote a script for the server side by myself as well,
  Here is the code (using python bottle web framework).</p>
  
  <pre><code>@route('/events')
  def positions():  
      response.content_type = 'text/event-stream'
      response.set_header('Cache-Control', 'no-cache')
      now = datetime.datetime.now().time().replace(microsecond=0)
      return  "data: %s\n\n"%now
  </code></pre>
  
  <p>And i get the same thing. Reconnecting every 3-4 seconds.</p>
  
  <p>So what I'm interested is in how the connection is kept through the session.</p>
  
  <p>Thanks for your help,
  Omer.</p>