WebSocket

A protocol that turns an HTTP connection into a long-lived, two-way channel where client and server can each send messages at any time.

In more detail

It starts as an HTTP request asking to upgrade. Afterwards messages need their own contract: event types, payload shapes, sequence numbers, size limits and close codes. Clients must reconnect with backoff, resume from a known position and re-authenticate, and both sides need backpressure.

Examples

Current Node.js has a global WebSocket client built in; a server still needs the upgrade event on node:http or a library such as ws.
A chat subscription is a classic React Effect: open the connection in setup and close it in cleanup.

Related terms

Taught in

References

Certification courses