How does a WebSocket connection start, and what happens after the HTTP Upgrade handshake?
Answer
In the classic HTTP/1.1 flow the client sends a GET request with Upgrade: websocket, Connection: Upgrade, Sec-WebSocket-Key and Sec-WebSocket-Version, and a browser also sends Origin. A successful server replies with 101 Switching Protocols and Sec-WebSocket-Accept. After the handshake, the application no longer exchanges ordinary HTTP request/response pairs on that connection; it exchanges WebSocket text, binary and control frames. Ping/Pong support liveness and Close frames perform a closing handshake. One logical message can be fragmented across multiple frames.
Strong answer includes
- HTTP Upgrade and 101 Switching Protocols
- Sec-WebSocket handshake headers
- text/binary/control frames after upgrade
Practical example
DevTools shows a successful 101 response, but the UI still receives no chat messages. That means the transport handshake succeeded and the next investigation should move to subscriptions, message schema, authorization, server publishing and frame traffic rather than the HTTP status alone.