4 ms·
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 num
by r3trohack3r 5y 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…
- toomim 5y agoPerhaps 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.
- tehbeard 5y ago...or we just keep moving to http/2 which avoids this limit.
- toomim 5y agoThat'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
- divbzero 5y agoThe limit applied only to browsers which have all implemented HTTP/2 at this point.
- toomim 5y agoYes, the limit is implemented in browsers, but it's for the protection of servers. The idea is to prevent a web app from DDOSSing a server somewhere. This is especially a problem for servers implemented with one thread or process per connection, rather than an async event queue like nodejs, because each thread takes up a few megabytes of memory, and if a browser opens 1000 connections, that's 2 gigs of memory right there. But if a server is implemented properly to support long-lived connections (by using node, or greenlets, or other async system) then it should be able to opt out of that browser protection. A standardized header would allow a server to opt out of it.
- divbzero 5y ago> I don’t understand how I’ve never observed the connection limit of 6… Practically speaking this limitation has been obsolete for 5 years or so. With HTTP/1.1 there used to be ways to achieve more parallel downloads through domain sharding [1] on the server side and browser tweaks [2] on the client side. [1]: https://developer.mozilla.org/en-US/docs/Glossary/Domain_sharding https://developer.mozilla.org/en-US/docs/Glossary/Domain_sha... [2]: http://kb.mozillazine.org/Network.http.max-persistent-connections-per-server http://kb.mozillazine.org/Network.http.max-persistent-connec...
- thayne 5y agoThis 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_sharding https://developer.mozilla.org/en-US/docs/Glossary/Domain_sha...