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

WebSockets and Server-Sent Events

WebSockets and Server-Sent Events, or SSE, are browser technologies for receiving updates over a long-lived connection. A WebSocket becomes a two-way message channel. SSE keeps an HTTP response open so the server can stream text events to an EventSource client.

Both approaches reduce repeated polling when data changes independently of a page request. They solve different communication problems. WebSockets suit interactive traffic in both directions. SSE suits a server-to-browser feed when client commands can continue through ordinary HTTP requests.

Two connection shapes

A browser starts a WebSocket with an HTTP opening handshake. With HTTP/1.1, the client requests an upgrade and a successful server returns status 101. The connection then carries WebSocket frames rather than ordinary HTTP messages. Either endpoint can send a message at any time.

An SSE client makes an HTTP request whose response uses text/event-stream. The response remains open. The server writes UTF-8 fields such as event, data, id, and retry. A blank line ends one event block and lets the browser dispatch it. The browser does not send application messages back on that stream.

This directional difference is the central design choice:

Continue the course

This section is part of the paid course.

See pricing to subscribe, or log in if you already have access.

Where this skill leads

Relevant careers

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

Sources