Protocols

Server-sent events

Server-sent events stream text events from an HTTP server to a client.

BrowserServerGET /streamdata: Hellodata: worlddata: [DONE]
Server-sent events stream text events from an HTTP server to a client. Values shown in the worked visual are illustrative unless the labels state otherwise.

How it works

The browser keeps one response open and processes event frames as they arrive. The channel is one-way, so client commands use separate requests.

A concrete example

Illustrative: stream 80 generated-token events followed by one done event.

Do not confuse it with WebSocket

SSE is server-to-client over HTTP; WebSocket is bidirectional.

Study the full lesson