Live data from Hacker News

Server-sent events

developer.mozilla.org

1–10 of 111 posts

Re: Server-sent events

#2
I 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 did this because we found the following to be true:

- At any given time, there are far more people reading chat messages than writing them

- What matters is that updates after being sent to everyone else is that their pretty close to instantaneous but you had a 500ms window to allow for the server to receive a new message and then propagate it out. Therefore, for the sender, you update the UI optimistically so they aren't waiting for a response, and everyone else will get it in ~500ms and its imperceptible

- one downside: its harder (we never figured it out before I left) to do indicators for when someone is typing. That really does seem to require two way real time connections

Re: Server-sent events

#4
Love 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?

Re: Server-sent events

#5
Curious why is this trending? Btw sse are pretty great, only thing I don't get is why they don't allow for binary payloads. That'd have been the icing on the cake.

Re: Server-sent events

#7

Love 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?

Try sending the messages without compression. A lot of servers don't know how to handle this for SSE (since its a uncommon content type)

Re: Server-sent events

#8
post #5

Curious why is this trending? Btw sse are pretty great, only thing I don't get is why they don't allow for binary payloads. That'd have been the icing on the cake.

> only thing I don't get is why they don't allow for binary payloads

I've always appreciated that it's just a simple line-oriented UTF-8 text protocol. Binary transfers are handled more efficiently with something else. Or just base64 the payload if it's not that big of a deal.

Re: Server-sent events

#9
For my fellow high-IQ individuals initially confused by the seeming lack of content in the article, it's under 'Guides': https://developer.mozilla.org/en-US/docs/Web/API/Server-sent...

A bit easy to miss, but includes some actual code samples and a really nice walkthrough. Highly encouraged even if you already "know" SSE and want to solidify your knowledge, I like how it doesn't hide any of the details.

Post reply on HN