v154 · websocket options
Subprotocol negotiation
Six real handshakes against the same endpoint, each offering a different set. The rule that surprises people is in row three: the client's order is a list of what it can speak, not a ranking — the server picks, and it picks by its own preference.
Six offers, one server
The endpoint knows echo.v2, echo, chat and soap, in that preference order. Every row opens a genuine connection and reports the server's own account of what it saw.
| what the client offered | opened? | negotiated | expected | as expected? |
|---|---|---|---|---|
| Not run yet. | ||||
the rules, as exercised above
- Offering nothing opens a connection with no subprotocol. That is not a failure — most sockets do not use one.
- Offering several does not rank them. The server chooses, and a server that prefers
echowill take it even whenchatcame first. - Offering only things the server does not know is a failed handshake, not a plain connection: the server has no protocol it can agree to.
- A duplicate in the list is a construction error before any request is sent.