openskills.info
Course Preview

WebSockets and Server-Sent Events

WebSockets and Server-Sent Events keep a browser connected to a server so updates can arrive without repeated polling. WebSockets carry messages in both directions, while Server-Sent Events stream text events from server to browser over HTTP.

itWeb development

Don't Panic: WebSockets and Server-Sent Events

WebSockets and Server-Sent Events are what happens when a browser page stops asking, "Has anything changed yet?" every few seconds. Both keep a connection open so updates can arrive when the server has them. The useful distinction is pleasantly unromantic: a WebSocket is a two-way message channel, while SSE is an HTTP response that keeps sending text events from server to browser.

Direction does most of the choosing. A build log, dashboard, notification feed, or generated-text stream usually has one author, the server, so SSE fits without inventing an upstream message channel. Collaborative editing, a terminal, a game, or signaling has two independent talkers, so WebSocket earns its extra machinery. When updates are rare, polling remains a respectable answer. A permanent connection is not a loyalty oath.

Reconnection is the bit that tends to arrive wearing a reassuring hat and then leave the application holding the bill. EventSource reconnects, and a WebSocket client can reconnect, but neither action restores the state that existed before the break. An event identifier is a bookmark, not a time machine. Important streams need a snapshot or retained history, sequence rules, and duplicate handling before they can claim recovery.

Long-lived connections also turn capacity into a different kind of arithmetic. Requests per second still matter, but so do concurrent connections, memory, file descriptors, proxy timeouts, outbound bandwidth, and the number of clients that decide to reconnect together. TLS protects the link. It does not decide who may subscribe, what a message means, or whether a slow client should stay connected forever. Those are application decisions, which is slightly rude of them, but also useful to know early.

Read the intro for the transport shapes and security boundaries. Use the slides when you need the comparison in one pass, and the cheatsheet when a field name, lifecycle state, or proxy check has escaped at an inconvenient moment. The practice reference and exercise turn the SSE format into a local stream. Field Notes is where the operational costs stop being theoretical.

Where this skill leads

Relevant careers

See how this topic contributes to broader role-level skill maps.

Sources