News for hackers. Stuff that matters.
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by ajvpot on Monday March 18, 2024 @01:51PM (#39747600)
I agree. Unfortunately you can only have 6 SSE streams per origin per browser instance, so you may be limited to 6 tabs without adding extra complexity on the client side.

https://crbug.com/275955

Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by TheP1000 on Monday March 18, 2024 @01:53PM (#39747641)
Is above still an issue with http2/3?

edit: From the article: To workaround the limitation you have to use HTTP/2 or HTTP/3 with which the browser will only open a single connection per domain and then use multiplexing to run all data through a single connection.

Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by gorjusborg on Tuesday March 19, 2024 @09:38AM (#39755620)
No, if you can enable TLS and HTTP/2|3, you are only technically using a single browser connection, onto which multiple logical connections can be multiplexed.

I think the article calls this out. There is still a limit on the number of logical connections, but it's an order of magnitude larger.

Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by andrewmutz on Monday March 18, 2024 @02:07PM (#39747816)
You can get around that limit using domain sharding, although it feels a bit hacky.
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by nine_k on Monday March 18, 2024 @02:23PM (#39747994)
Can the tabs share a background worker that would handle that?
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by merb on Monday March 18, 2024 @02:27PM (#39748040)
You can use https://www.npmjs.com/package/broadcast-channel which creates a tab leader, no need for a background worker

Edit: of course you could use: https://caniuse.com/sharedworkers but android does not support it. We migrated to the lib because safari took its time… so mobile was/is not a thing for us

Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by nchmy on Tuesday March 19, 2024 @10:59AM (#39756397)
Here's the chrome android issue for Shared Workers. Add your voice if it is something you need

https://issues.chromium.org/issues/40290702

Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by ravxx on Monday March 18, 2024 @01:55PM (#39747661)
just use a service worker to share state, you would be much better off doing this anyways. saves a ton and is performant.
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by simonw on Monday March 18, 2024 @02:01PM (#39747739)
I think you need a SharedWorker for that rather than a service worker https://developer.mozilla.org/en-US/docs/Web/API/SharedWorke...
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by jedschmidt on Monday March 18, 2024 @10:11PM (#39752305)
A service worker would work fine; the connection would be instantiated from the SW and each window/worker could communicate with it via navigator.serviceWorker.
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by esprehn on Tuesday March 19, 2024 @12:45AM (#39753021)
That doesn't work because browsers have duration limits on ServiceWorkers:

https://github.com/w3c/ServiceWorker/issues/980#issuecomment...

Also unfortunately Chrome doesn't keep SharedWorker alive after a navigation (Firefox and Safari do):

https://issues.chromium.org/issues/40284712

Hopefully Chrome will fix this eventually, it really makes it hard to build performant MPAs.

Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by jedschmidt on Tuesday March 19, 2024 @07:07AM (#39754571)
In my experience, as long as a controlled window is communicating with the SW, the connection will remain alive.
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by nchmy on Tuesday March 19, 2024 @10:58AM (#39756388)
Shared workers (inexplicably) dont exist on Android Chrome

https://issues.chromium.org/issues/40290702

Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by simonw on Monday March 18, 2024 @01:57PM (#39747697)
Is that true if you are using HTTP/2?
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by cassepipe on Monday March 18, 2024 @07:19PM (#39751223)
Nope. That's only a problem with HTTP/1.1
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by hobobaggins on Monday March 18, 2024 @08:20PM (#39751648)
Yes, but the limit is different (usually much higher) and negotiated, up to maximum SETTINGS_MAX_CONCURRENT_STREAMS (which is fixed at 100 in Chrome, and apparently less in IOS/Safari.)
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by paulddraper on Monday March 18, 2024 @07:13PM (#39751189)
HTTP 2/3 doesn't have they limitation.

For HTTP 1, simply shard the domain.

Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by xialvjun on Tuesday March 19, 2024 @05:41AM (#39754135)
just one tab use SSE and others use storage event.