# What is WebSocket? Also called WebSockets, WS. WebSocket is a standardized protocol that upgrades an HTTP connection into a persistent, full duplex channel over a single TCP connection. Once the handshake completes, either side may send message frames at any time without waiting to be asked. It is specified in RFC 6455 and is supported natively by browsers through the WebSocket JavaScript interface. A WebSocket session begins as an ordinary HTTP request carrying an Upgrade header. If the server agrees, the same TCP connection switches to the WebSocket framing protocol and both parties keep it open. Because the handshake is HTTP, the connection traverses most proxies and firewalls that allow web traffic, and it can reuse the same port and TLS setup as the rest of a site. The defining property is symmetry. Unlike request and response protocols where the client must ask before it can receive anything, a WebSocket server can push a message the instant it has one. This suits collaborative editors, live dashboards, multiplayer state, and streaming assistant output where latency matters and the number of updates is unpredictable. Operationally, persistent connections shift the cost model. Each open socket consumes server memory and a file descriptor, load balancers must be configured for long lived connections and sticky routing, and the application must implement its own heartbeat, reconnect, and backoff logic because networks drop idle connections silently. Message ordering is guaranteed within a connection but nothing survives a reconnect unless the application resends it. Security follows web rules only partly. The browser same origin policy does not block WebSocket handshakes, so servers must validate the Origin header and authenticate the session explicitly rather than assuming a cookie is sufficient. The encrypted scheme is wss, and production deployments should require it. ## Key points - Starts as HTTP, upgrades to a persistent full duplex channel - Server can push without being polled - Specified in RFC 6455; encrypted variant is wss - Needs heartbeats, reconnect, and backoff logic - Validate Origin; same origin policy does not apply ## In practice A workspace dashboard opens one WebSocket when the page loads. As a background job progresses, the server pushes small JSON frames carrying status updates, and the browser updates a progress indicator in place. When the user submits a comment, it travels up the same connection. If the socket drops, the client waits with exponential backoff, reconnects, and requests any state it missed. ## Related terms - [Server-Sent Events](/en/glossary/server-sent-events) - [Long Polling](/en/glossary/long-polling) - [Streaming Response](/en/glossary/streaming-response) - [API](/en/glossary/api) - [Webhook](/en/glossary/webhook) [Back to the AI Glossary](/en/glossary)