Opening handshake
01The client requests WebSocket version 13. A valid switching response proves the server understood this handshake.
Application data uses WebSocket frames after the opening handshake succeeds.
Key idea: Validate the handshake before sending WebSocket data.
Rules & examples
Validate the handshake before sending WebSocket data.
- The HTTP/1.1 handshake uses GET, Upgrade: websocket, Connection: Upgrade, and Sec-WebSocket-Version: 13.
- The server returns 101 and a Sec-WebSocket-Accept value derived from the client key and a fixed GUID; the client checks it.
- Origin checks protect browser-based use, but Origin is not authentication for arbitrary non-browser clients. Use wss for TLS protection.
The key/accept exchange is a protocol check, not password authentication. Applications still need their own authorization policy. Subprotocols and extensions must be negotiated explicitly.
Sources
New to this? Start hereA quick picture + helpful background
A request starts a conversation.
A client asks for a resource. A server sends a response. The method, address, headers, and status explain what that conversation means.
Helpful first, if these ideas are unfamiliar
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.
The later HTTP/2 bootstrap uses extended CONNECT with :protocol set to websocket. It replaces the HTTP/1.1 Upgrade and 101 exchange for that mapping; it does not define WebSocket version 14.
Read the updated RFC section ↗