← Back to context

Comment by r3trohack3r

3 years ago

Had never heard of SSE before. Followed the link and found this warning:

> Warning: When not used over HTTP/2, SSE suffers from a limitation to the maximum number of open connections, which can be especially painful when opening multiple tabs, as the limit is per browser and is set to a very low number (6). The issue has been marked as "Won't fix" in Chrome and Firefox. This limit is per browser + domain, which means that you can open 6 SSE connections across all of the tabs to www.example1.com and another 6 SSE connections to www.example2.com (per Stackoverflow). When using HTTP/2, the maximum number of simultaneous HTTP streams is negotiated between the server and the client (defaults to 100).

This is the first time I’ve heard of per-domain connection limits. Seems… not great? Doesn’t this turn into a client side DoS? User opens 6+1 tabs and now the browser has exhausted all HTTP connections to your domain serving SSE connections?

I’ve used long polling before, I don’t understand how I’ve never observed the connection limit of 6…

This limit was(/is) actually a common problem with HTTP/1.1, and was one of the motivations for HTTP/2. A common workaround is "domain sharding"[1] where you would split your site up between several domains, so that you could get more concurrent connections. Which is important for improving page load time, but doesn't really help with having SSE for multiple tabs (unless you do something crazy like using a randomly generated domain for each SSE connection).

[1]: https://developer.mozilla.org/en-US/docs/Glossary/Domain_sha...

Perhaps we should define a new HTTP header for servers to say: "It's ok for clients to initiate N connections with me" so that we can write web apps without this restriction.

  • ...or we just keep moving to http/2 which avoids this limit.

    • That'd be great, but is a lot harder than adding a header. HTTP/2 changes the entire wire format into a binary protocol that multiplexes multiple streams over a single connection. It's a lot harder to implement than HTTP/1, which you can type out manually over telnet:

          telnet news.ycombinator.com 80
      
          GET / HTTP/1.1
          Host: news.ycombinator.com
          \n
          \n
      

      Adding a header could be as simple as:

          HTTP/1.1 200 OK
          Content-Type: text/html; charset=utf-8
          Multiple-Subscriptions: OK

      2 replies →