4.4. Supporting multiple versions of WebSocket protocol

This section provides some guidance on supporting multiple versions of the WebSocket protocol in clients and servers.

Using the WebSocket version advertisement capability (the “Sec- WebSocket-Version” header field) client can initially request the version of the WebSocket protocol that it prefers (which doesn’t necessarily have to be the latest supported by the client). If the server supports the requested version and the handshake message is otherwise valid, the server will accept that version. If the server doesn’t support the requested version, it will respond with a Sec- WebSocket-Version header field (or multiple Sec-WebSocket-Version header fields) containing all versions it is willing to use. At this point, if the client supports one of the advertised versions, it can repeat the WebSocket handshake using a new version value.

draft-ietf-hybi-thewebsocketprotocol-14 – The WebSocket protocol から2011年9月11日0時43分に引用

ブラウザやサーバによってサポートしているwebsocketのバージョンがまちまちなのでDraft 76でSec-WebSocket-Versionフィールドがサポートされたが、さらに複数のバージョンを指定できるようになった。


GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 25


HTTP/1.1 400 Bad Request
Sec-WebSocket-Version: 13
Sec-WebSocket-Version: 8, 7


Written on September 11, 2011