WebSocket API
Persistent, bidirectional
Why it exists
- Real-time communication without polling
- Server can push updates anytime
- Single long-lived connection
Tradeoffs
- More complex than HTTP request/response
- Scaling requires sticky sessions or pub/sub
ws://host:port/ws — connect once, send and receive anytime
Connection
Disconnected
Persistent connection — bidirectional
C
Clientsend
receive
S
ServerMessage log
Connect and send messages to see them here.