Bug Description
- client sends
Sec-WebSocket-Protocol header with protocol list (separated by ',')
- server responds with one protocol from this list
- WebSocket client compares request header (protocol list) with response header (one protocol) value and fails with the error
Protocol was not set in the opening handshake
|
if (secProtocol !== null && secProtocol !== request.headersList.get('Sec-WebSocket-Protocol')) { |
Reproducible By
let ws = new WebSocket('ws://server...', ['msgpack', 'json'])
ws.addEventListener('error', e => console.log(e.error))
// server choses json and responds with `Sec-WebSocket-Protocol: json`
// client failed
Expected Behavior
Correct subprotocol check
Environment
- Node.js v21.6.2
--experimental-websocket flag
Bug Description
Sec-WebSocket-Protocolheader with protocol list (separated by ',')Protocol was not set in the opening handshakeundici/lib/web/websocket/connection.js
Line 179 in c49058b
Reproducible By
Expected Behavior
Correct subprotocol check
Environment
--experimental-websocketflag