Hacker News new | ask | show | jobs
by remram 1574 days ago
I thought it reconnected automatically, and sent the last received event ID? Why do you need heartbeat?

Why don't you want to send the event to all the tabs? Why do you want to differentiate the tabs (by UUID)?

1 comments

Yeah my personal experience is that if a SSE server has clients subscribed, and it goes down, the clients reconnect automatically once the server starts back up.

Only thing is the message ids reset when this happens.

I think this depends on the client/implementation. SSE call is just a http request with a continuous body stream. If it gets terminated clients could try to make another of those requests or not. That said the EventSource client in Browsers - which most people are likely using- will automatically reconnect
The SSE spec contains the `retry` and `Last-Event-ID` mechanism. Of course if you are making your own implementation, nothing is provided, but I'm saying that the spec has such mechanisms built-in.

https://html.spec.whatwg.org/multipage/server-sent-events.ht...