connectWebSocket
connectWebSocket(
requester,url,options):Promise<WebSocketPeer>
Defined in: packages/net-websocket/src/handshake/connect-websocket.ts:75
Open a WebSocket: send the opening handshake through requester, check the
server’s answer, and return the peer over the connection it handed over.
ws: and wss: URLs are requested as http: and https:. The request is a
CONNECT with protocol websocket, which HTTP/1.1 sends as its Upgrade
handshake and HTTP/2 and HTTP/3 as an extended CONNECT (RFC 8441, RFC
9220).
Over HTTP/1.1 the response must be a 101 with Upgrade: websocket, the
Sec-WebSocket-Accept matching the key sent; over HTTP/2 and HTTP/3, a
2xx. Either way it must choose no extension (none is offered), and a
subprotocol only from those offered.
Parameters
Section titled “Parameters”requester
Section titled “requester”URL
options
Section titled “options”Returns
Section titled “Returns”Promise<WebSocketPeer>
Throws
Section titled “Throws”When the server refuses or answers incorrectly.
Throws
Section titled “Throws”When the request fails, or options.signal aborts first.