WebSocket

DEVELOPMENT

Quick Definition

WebSocket is a communication protocol that provides a persistent, full-duplex (two-way) connection between a client (usually a browser) and a server. Unlike regular HTTP requests, a WebSocket connection stays open, allowing data to flow in both directions in real time.

How it works

A WebSocket connection begins with a standard HTTP request called the "handshake." The client sends an upgrade request, and if the server supports WebSockets, it responds with a 101 status code, switching protocols. From that point on, the connection remains open, and both sides can send messages at any time without the overhead of establishing new connections.

With traditional HTTP, the client must initiate every exchange. If you want live updates, you have to keep asking the server ("polling"), which wastes bandwidth and adds latency. WebSockets eliminate this pattern: the server pushes new data to the client the moment it is available. This makes WebSockets ideal for live price feeds, chat applications, multiplayer games, and any scenario where millisecond-level freshness matters.

WebSocket messages can be text or binary, and the protocol has built-in ping/pong frames to keep the connection alive. If the connection drops, the client typically reconnects automatically. Server-Sent Events (SSE) are a simpler alternative for one-way server-to-client streaming.

Why it matters

WebSockets power the real-time web. Without them, live dashboards, collaborative editors, and instant messaging would rely on inefficient polling. For developers building data-intensive applications, understanding when to use WebSockets versus REST or SSE is a key architectural decision.

Where you'll see this on TerminalFeed

The TerminalFeed dashboard uses WebSocket connections for several live panels: the BTC Price panel streams from Binance's WebSocket API, the Earthquake panel connects to Seismic Portal, and the Wikipedia Live Edits panel uses SSE from Wikimedia. These connections provide sub-second updates without constant polling.