WebSockets
WebSocket (RFC 6455, IETF, Dec 2011) gives full-duplex framing over one TCP connection reached via an HTTP Upgrade handshake; the browser JS API is a separate WHATWG Living Standard, last revised March 2026. It's a royalty-free open protocol (no license fee), supported by roughly 97% of browsers per caniuse (96.93% global usage) and every browser shipped since 2013. Framing overhead is 2-6 bytes per message after handshake, versus roughly 600 bytes of headers on a comparable HTTP request, the reason it beats polling and SSE under high message frequency. Extensions add permessage-deflate compression (RFC 7692), HTTP/2 bootstrapping (RFC 8441), and HTTP/3 (RFC 9220). Node's `ws` package alone logs roughly 224M npm downloads/week in 2026; Socket.IO, its most common wrapper, layers in automatic transport fallback. Current version/status: RFC 6455 wire protocol (Dec 2011, unchanged); WHATWG browser API Living Standard, last revised March 2026. License: Open IETF/WHATWG standard, royalty-free, no license required. Maintained by IETF (wire protocol, RFC 6455) and WHATWG (browser JavaScript API, Living Standard).
Pick WebSocket when you need low-latency, high-frequency, bidirectional traffic through a browser: multiplayer state sync, trading tickers, collaborative editors, where SSE's one-way stream or MQTT's broker overhead don't fit. Skip it for simple server-push (stock ticker, notification feed): SSE rides plain HTTP, auto-reconnects, and survives corporate proxies that WebSocket's upgrade handshake can get blocked by, at a fraction of the code. Skip it for constrained IoT fleets too: MQTT's 2-byte header and QoS levels beat WebSocket's chattier framing on cellular/LPWAN links. The protocol's own acknowledged weakness: no built-in reconnection, backpressure, or message framing beyond raw bytes/text, so production use almost always means bolting on a library like Socket.IO or hand-rolling a reconnect/heartbeat layer. Known weakness: The spec defines only framing and a handshake, not reconnection, backpressure, or message semantics, so every real deployment ends up shipping a wrapper library or hand-rolled heartbeat/reconnect logic on top.
See how it ranks →