EN
Back to the archive

The encyclopedia · Software & IT · Technical decision · 2008-2011

WebSocket upgraded an HTTP handshake over ports 80 and 443 to get a full-duplex channel

WebSocket reused the HTTP Upgrade handshake on ports 80 and 443, so realtime traffic passed through existing firewalls.

IETF · WHATWG

the move

For years, a web page wanting live data had to fake it with long-polling, so it opened and closed HTTP requests over and over. Flash and Comet channels worked but were heavy and brittle. The theoretical fix is a new dedicated port and protocol, which is exactly what most corporate firewalls block.

WebSocket instead reuses the ports everyone already allows. It performs a handshake using the HTTP Upgrade header, and once the server answers 101, the same TCP connection flips over to a full-duplex message channel. It looks like an ordinary HTTP request to any proxy, then becomes something else.

Because it rides the existing ports and the browser's origin security model, it needed no infrastructure change. Once browsers enabled it, the standard was finalized in 2011 and realtime web apps became trivially deployable.

why it works

  • By reusing ports 80 and 443, WebSocket sails through firewalls that block any unknown port, so deployment is instant.
  • The Upgrade handshake makes the connection look like a normal HTTP request to intermediaries, so proxies survive.
  • It replaces long-polling and Flash with one open connection, cutting per-message overhead dramatically.
  • It keeps the browser's origin-based security model, so untrusted code cannot just open arbitrary sockets.
the payoffBorrow the HTTP port and upgrade that connection.clever

what transfers

A platform and port that already traverse every firewall is a surer route to adoption than the technically cleaner new protocol that must punch through them.

what came after

RFC 6455 was finalized in December 2011 and became the realtime transport used by chat, games, financial tickers and collaborative tools. It later faced pressure from HTTP/2 and HTTP/3 multiplexing and from WebTransport, but remains the standard way browsers hold an open two-way socket.

references

spotted an error? The archive wants to know.

same kind of clever