News for hackers. Stuff that matters.
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by skybrian on Monday March 18, 2024 @02:03PM (#39747746)
This is probably naive, but it seems like assuming HTTP/2 or better, an EventSource combined with fetch() for sending messages should be just as good as any other protocol that uses a single TCP connection? And HTTP/3 uses UDP, so even better.

(This all assumes you only care about maintaining a connection when the tab is in the foreground.)

I’m wondering what problems people have run into when they tried this.

Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by apitman on Monday March 18, 2024 @04:40PM (#39749730)
One limitation is SSE is text-only, so you can't efficiently send binary data. You have to encode it as base64 or similar.
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by niutech on Saturday March 23, 2024 @07:04AM (#39798995)
There is another alternative to base64: https://github.com/luciopaiva/binary-sse
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by jacobr1 on Monday March 18, 2024 @03:09PM (#39748596)
This presumes the majority of your use case is server-client, but otherwise yes.
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by ksec on Monday March 18, 2024 @08:56PM (#39751884)
Was thinking exactly the same thing. H2 with SSE solves 99% of problems? I was wondering if we could push SSE even further along with lower latency, memory usage and CPU resources than doing something completely different.
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by nchmy on Tuesday March 19, 2024 @11:04AM (#39756459)
This library does what you are looking for

https://www.npmjs.com/package/@microsoft/fetch-event-source