Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I got interested and found this nice thread on SO: https://stackoverflow.com/a/5326159

One of the drawbacks, as I learned - SSE have limit on number of up to ~6 open connections (browser + domain name). This can quickly become a limiting factor when you open the same web page in multiple tabs.



I've gotten around this by using the Page Visibility API - https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibi.... Close the SSE connection when the page is hidden, and re-open when it becomes visible again.


As the other two comments mentioned, this is a restriction with HTTP/1.1 and it would apply also to long polling connections as well.


Syncing state across multiple tabs and windows is always a bit tricky. For SSE, I'd probably reach for the BroadcastChannel API. Open the SSE connection in the first tab and have it broadcast events to any other open tab or window.


…if you’re using http/1.1. It’s not an issue with 2+


Not an issue if you’re using HTTP/2 due to how multiplexing happens.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: