News for hackers. Stuff that matters.
Re:HTTP Feeds by r3trohack3r on Monday April 04, 2022 @10:25AM (#30906982)
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…

Re:HTTP Feeds by thayne on Monday April 04, 2022 @12:41PM (#30908736)
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...

Re:HTTP Feeds by divbzero on Monday April 04, 2022 @12:37PM (#30908675)
> 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_sha...

[2]: http://kb.mozillazine.org/Network.http.max-persistent-connec...

Re:HTTP Feeds by toomim on Monday April 04, 2022 @12:26PM (#30908530)
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.
Re:HTTP Feeds by tehbeard on Monday April 04, 2022 @12:33PM (#30908619)
...or we just keep moving to http/2 which avoids this limit.
Re:HTTP Feeds by toomim on Monday April 04, 2022 @12:39PM (#30908692)
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
Re:HTTP Feeds by divbzero on Monday April 04, 2022 @01:34PM (#30909523)
The limit applied only to browsers which have all implemented HTTP/2 at this point.
Re:HTTP Feeds by toomim on Monday April 04, 2022 @03:44PM (#30911151)
Yes, 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.