Source
WebSocket
Definition of the protocol, upgrade and messaging features.
WebSocket is an application layer protocol that opens a persistent two-way communication channel between a client and a server. It is built on top of HTTP Upgrade and is suitable for scenarios where frequent updates and minimal latency are needed.
How WebSocket works
Upgrade from HTTP
The connection starts as a normal HTTP request and switches to a WebSocket via Upgrade headers.
Full duplex
The client and server can send messages independently and simultaneously.
Long-lived connections
The channel remains open, reducing the overhead of reconnections.
Message Frames
Data is sent as WebSocket frames with a type and payload.
Upgrade and Messaging
First, a regular HTTP connection is upgraded to WebSocket, after which the channel becomes permanent and supports the exchange of messages in both directions.
HTTP → WebSocket Upgrade
Click a step or use the controls to replay the upgrade and message exchange
State
Click "Start" to see the transition process from HTTP to WebSocket.
The connection is open and ready for message exchange.
Details
Key headers and message examples will appear here.
Where WebSocket fits best
- Chats and collaborative editors
- Live dashboards and monitoring
- Online games and realtime interaction
- Trade and financial flows
- Signaling for WebRTC
