WebSocket
Subject: Computer and Technology noun /ˈwɛbˌsɑː.kɪt/ 1 definition
- computer-networking
- network-protocols
- web-development
- real-time-communication
-
Definition (noun)
Entry #93 · UpdatedWebSocket is a standardized application-layer communication protocol (RFC 6455) that establishes a persistent, full-duplex, bidirectional messaging channel between a client and a server over a single TCP connection. A session typically begins with an HTTP handshake using the
Upgrademechanism and transitions into a lightweight framing layer that lets either peer push UTF-8 text or binary messages independently with minimal per-frame header overhead. By eliminating repeated HTTP connection handshakes, verbose headers, and polling intervals, WebSocket enables low-latency, real-time data exchange while leaving message routing, subscription models, and payload schemas to higher-level subprotocols or application logic.Common Forms
Unencrypted WebSocket (
ws://): Transmits WebSocket frames in plaintext over TCP (defaulting to port 80), generally restricted to local development or trusted internal networks because intermediaries can inspect or interfere with unencrypted traffic.Secure WebSocket (
wss://): Runs the WebSocket handshake and framing inside a Transport Layer Security (TLS) tunnel (defaulting to port 443), providing confidentiality, message integrity, and reliable traversal through firewalls and reverse proxies.Subprotocol-Negotiated WebSocket: Establishes an agreed-upon messaging contract during the handshake via the
Sec-WebSocket-Protocolheader, layering conventions such as STOMP, MQTT, or GraphQL subscriptions atop raw WebSocket frames.Multiplexed WebSocket (HTTP/2 and HTTP/3): Bootstraps bidirectional WebSocket byte streams inside multiplexed HTTP/2 (RFC 8441) or QUIC-based HTTP/3 (RFC 9220) sessions using an extended
CONNECTrequest rather than dedicating a separate TCP socket per channel.
Example
When a trader opens a live market dashboard, the browser connects to
wss://stream.exchange.example/quotes, completes a TLS handshake, and sends an HTTPGETrequest containingUpgrade: websocket, receiving a101 Switching Protocolsresponse from the server. Over that single persistent connection, the server continuously pushes order-book price updates in lightweight WebSocket frames while the client simultaneously sends ticker subscription changes without initiating new HTTP requests.