Devii · Backend · 2026-04-04 · 7 min read

Share

WebSockets: Full-Duplex Channels Over A Single TCP Connection

RFC 6455 mechanics: opening handshake, frames, and when SSE or HTTP polling is simpler.

The **WebSocket Protocol** (RFC 6455) upgrades an HTTP/1.1 connection (or uses HTTP/2 extended CONNECT in some stacks) to a persistent, full-duplex channel. Clients and servers send **frames** with opcodes for text, binary, ping/pong, and close.

Use WebSockets when the server must push frequently to many clients (collaborative editors, live tickers, game state). For mostly server-to-client streams, **Server-Sent Events** can be simpler and friendlier to HTTP caches.

Load testing dashboard
Load testing dashboard

Operational concerns: idle timeouts on load balancers, sticky sessions if you lack a shared pub/sub backplane, and message size limits. Authenticate during the handshake or first message; do not rely on cookies alone across misconfigured proxies.

Libraries (Socket.IO, ws, uWebSockets) add heartbeats and fallbacks; understand what the raw RFC provides versus your framework.