I'm a little confused by how this is used. The trivial example provided on developer.mozilla.org is a PHP script that's fully self-contained. As far as I could tell, a self-contained PHP script doesn't provide much value. I would have expected something to happen on the server, like a database record getting updated, which triggers the PHP to send an SSE message to the browser, but how do you trigger that particular…
You could have some kind of event system running that pushes the event down to php. For instance, redis has a PUBSUB system, and postgresql has NOTIFY.
Server-sent events
91–100 of 111 posts
Re: Server-sent events
#92Earlier quoted context omitted.
The big problem i've run into with SSE is the connection limit [1]: > Warning: When not used over HTTP/2, SSE suffers from a limitation to the maximum number of open connections, which can be specially painful when opening various tabs as the limit is per browser and 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, so that means that you…
> The natural way to use SSE is to create an EventSource on each page. If you do this, and your user opens six tabs, they can now no longer make HTTP requests to your site. Not just SSE requests, any HTTP requests at all! You can use EventSource in a singleton worker and use postMessage to forward messages to all open browser tabs for the same origin.
If you have an answer to that answer I'd be very much interested
Re: Server-sent events
#93I know alot of websites and engineers use Websocket for push only data. SSE is tailored made for real time one sided updates! In fact, I think it made a better chat protocol, when we built a chat system at a previous job, similar to Slack. We ended up leveraging SSE to push updates to channels and traditional HTTP requests to send data to the server, resulting in lower latency and less overhead on the server side. We…
The big problem i've run into with SSE is the connection limit [1]: > Warning: When not used over HTTP/2, SSE suffers from a limitation to the maximum number of open connections, which can be specially painful when opening various tabs as the limit is per browser and 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, so that means that you…
Not an unreasonable requirement for a serious modern web app.
Re: Server-sent events
#94Earlier quoted context omitted.
> The natural way to use SSE is to create an EventSource on each page. If you do this, and your user opens six tabs, they can now no longer make HTTP requests to your site. Not just SSE requests, any HTTP requests at all! You can use EventSource in a singleton worker and use postMessage to forward messages to all open browser tabs for the same origin.
SharedWorker (the thing needed for a "singleton worker") only just made it into Safari the end of last year... plus you now have to handle multiplexing and demultiplexing for different tabs on both server and client. By the time that arrived and HTTP/2 had wide enough adoption, everyone's already used to building atop Websocket... Also the EventSource in the browser is heavily gimped. GET only, No custom headers, and…
I was looking at : https://stackoverflow.com/questions/61041389/managing-server...
Shared worker would actually allow for SSE in a service worker ! That's nice.
Re: Server-sent events
#95Earlier quoted context omitted.
The big problem i've run into with SSE is the connection limit [1]: > Warning: When not used over HTTP/2, SSE suffers from a limitation to the maximum number of open connections, which can be specially painful when opening various tabs as the limit is per browser and 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, so that means that you…
In short, it reads to me as "HTTP/2 or don't bother". Not an unreasonable requirement for a serious modern web app.
Re: Server-sent events
#96Earlier quoted context omitted.
I don't think I understand. Both WebSockets and server-sent events are just a long lived TCP socket, right? Why would SSE be lower overhead? Why wouldn't it be more overhead to go through the whole HTTP request handling machinery for EVRY chat message everyone sends? You already have an underlying 2-way connection in the TCP socket, why not use it? And why would latency be lower with HTTP requests + SSE than with web…
It's not. SSE has higher overhead and there are browser limits as to how many concurrent channels a single client can consume. Also, SSE encourages you to shift complexity to the back end where it would be more appropriate on the front end. For example, the client knows which channels it needs, so why not let the client decide which channels to subscribe to over a single WebSocket connection? With SSE, you end up hav…
Re: Server-sent events
#97Earlier quoted context omitted.
> The natural way to use SSE is to create an EventSource on each page. If you do this, and your user opens six tabs, they can now no longer make HTTP requests to your site. Not just SSE requests, any HTTP requests at all! You can use EventSource in a singleton worker and use postMessage to forward messages to all open browser tabs for the same origin.
This SO answer seems to say that it wouldn't work : https://stackoverflow.com/questions/61041389/managing-server... If you have an answer to that answer I'd be very much interested
Even on HTTP/2, I believe it's best avoid sending 6 times the same message to the user just because they opened 6 tabs. It's less wasteful both for the server and the client.
[1] https://developer.mozilla.org/en-US/docs/Web/API/BroadcastCh...
[2] https://github.com/tracim/tracim/blob/develop/frontend_lib/s...
Re: Server-sent events
#98Love to see stuff like this on the HN front page, when I know tons of web devs that have never even heard of SSE. Tangentially, I’m having a massive problem with SSE datastreams erroring out about two minutes in for “ERR: Network chunk encoding” reasons, anyone else seen this before?
You need to send "keep-alive" "noop" to keep the routers happy, I do it ever 5 seconds.
Re: Server-sent events
#99Earlier quoted context omitted.
You need to multi-thread your server on shared memory to build many-to-many solutions. The simplest way to get that working is Java + NIO with concurrent package, I have done it for you: http://github.com/tinspin/rupy My web server outperforms everything on the planet for multiplayer. Websockets are notoriously hard to parallelize if you want shared memory which you need for many-to-many, mostly because JavaScript an…
> You need to multi-thread your server on shared memory to build many-to-many solutions Not necessarily, it depends on the needs, but in any case I would not expect SSE and WebSockets to be different in this regard. I'm not sure what's specifically hard to parallelize with WebSockets. Shared memory may be hard to handle but that does not seem specific to WebSockets which are just regular two way communication channel…
I clearly said many-to-many, everything else is trivial to scale because only many-to-many requires strictly shared memory atomic parallelization.
You could write a better server in Java than javascript/c(++) but I haven't found any, and to be honest the extra complication of the binary protocol doesn't even make me curious enough to waste 5 seconds to google it.
SSE over HTTP/1.1 is the final solution. Everything else is a waste of time for eternity.
Re: Server-sent events
#100I fear years back I made a Monopoly Deal game with a client-server arch.
Server was in Go with SSE, and client was in JS/Svelte with SVG and a lot of CSS.
It work so so well ! The clientside cmds (like "place this card there") was vanilla ajax send to Go Server, but the "state" was always send via SSE to connected clients.
I was surprised to see how far Joe Average (Yea I use bootstrap for most things) can push CSS for nice looking card game.
PS: Oops I mean "WildDeal" not "Monopoly Deal", no need to get sued