From b22e3fbc8441561b645a82770a6f78e9efc145cd Mon Sep 17 00:00:00 2001 From: keith Date: Mon, 1 Nov 2021 22:06:26 -0700 Subject: [PATCH] fix: pass http.Agent through `connect` --- src/websocket-client.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/websocket-client.ts b/src/websocket-client.ts index e3829be..2eca7c7 100644 --- a/src/websocket-client.ts +++ b/src/websocket-client.ts @@ -510,7 +510,8 @@ export class WebsocketClient extends EventEmitter { private connectToWsUrl(url: string, wsKey: WsKey): WebSocket { this.logger.silly(`Opening WS connection to URL: ${url}`, { ...loggerCategory, wsKey }) - const ws = new WebSocket(url); + const agent = this.options.requestOptions?.agent; + const ws = new WebSocket(url, undefined, agent ? { agent } : undefined); ws.onopen = event => this.onWsOpen(event, wsKey); ws.onmessage = event => this.onWsMessage(event, wsKey); ws.onerror = event => this.onWsError(event, wsKey);