Sec-WebSocket-Version
The HTTP Sec-WebSocket-Version request and response header indicates the WebSocket protocol version during the protocol upgrade handshake.
Baseline: Widely available
Supported across all major browsers. webstatus.dev
Usage
The Sec-WebSocket-Version header is sent by the client when initiating a WebSocket connection upgrade from HTTP. The header value indicates which version of the WebSocket protocol specification the client implements and expects the server to support.
Version 13 is the current protocol version. All
modern browsers and WebSocket clients send this value. Earlier draft
versions used values like 8, 7, and 0 during the specification
development process, but these are now obsolete.
If the server does not support the version requested by the client, the server responds with status 426 Upgrade Required and includes Sec-WebSocket-Version in the response listing the versions the server supports. The client then decides whether to retry with a supported version or abandon the connection attempt.
When the server supports the requested version, the server omits Sec-WebSocket-Version from the response and completes the upgrade by sending Sec-WebSocket-Accept. The connection switches to WebSocket framing after the handshake completes.
Values
13
The value 13 represents the current protocol
version. This is the only version in active use.
Example
A browser requests a WebSocket Secure connection using protocol
version 13.
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Version: 13
The server supports version 13 and completes the upgrade without echoing
the version header.
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
If the server supports only older draft versions, the server rejects the upgrade and advertises supported versions.
HTTP/1.1 426 Upgrade Required
Sec-WebSocket-Version: 8, 7
Takeaway
The Sec-WebSocket-Version header communicates the WebSocket protocol
version during the upgrade handshake, with version 13 representing the
current standard.
See also
- RFC 6455: The WebSocket Protocol
- Sec-WebSocket-Key
- Sec-WebSocket-Accept
- Sec-WebSocket-Extensions
- 426
- Ws
- Wss
- Protocol-Upgrade
- HTTP headers