Server-Sent Events Deep Dive: The Event Stream Format
The precise SSE wire format from the WHATWG HTML spec: comment/keep-alive lines, multi-line data, the dispatch rule, named vs default events, the id and retry fields, stopping reconnection, and the reverse-proxy buffering gotcha. The parsing behavior here is verified with a spec-faithful parser in Node.
Questions
- Not answered. In an SSE stream, what does a line beginning with a colon (
:) do? - Not answered. A single SSE event contains two
data:lines. How is the payload delivered to the client? - Not answered. What part of the SSE wire format signals "this event is complete — dispatch it now"?
- Not answered. Your server sends events tagged
event: price, but the client'sonmessagehandler never fires. Why? - Not answered. Which statements about SSE field parsing are correct?
- Not answered. What does a
retry: 10000line do, and what's the constraint on its value? - Not answered. An
EventSourcereconnects on its own after a drop. Which 2xx HTTP status should the server return on (re)connect to make it give up and stop reconnecting? - Not answered. SSE works locally, but in production behind nginx the events arrive in big delayed bursts instead of one-by-one. Most likely cause and fix?
- Not answered. An event sets
id: 42. The next event has noid:line. If the client reconnects after that second event, whatLast-Event-IDdoes it send? - Not answered. Which statements about
EventSourcereconnection are correct? - Not answered. Why do SSE servers periodically send a comment line (e.g.
: ping) even when there's no real data to deliver?