Hacker News new | past | comments | ask | show | jobs | submit login

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.




One limitation is SSE is text-only, so you can't efficiently send binary data. You have to encode it as base64 or similar.


There is another alternative to base64: https://github.com/luciopaiva/binary-sse


This library does what you are looking for

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


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.


This presumes the majority of your use case is server-client, but otherwise yes.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: