diff --git a/lib/websocket.js b/lib/websocket.js index 4391c73ab..2bcfcf738 100644 --- a/lib/websocket.js +++ b/lib/websocket.js @@ -643,7 +643,6 @@ function initAsClient(websocket, address, protocols, options) { followRedirects: false, maxRedirects: 10, ...options, - createConnection: undefined, socketPath: undefined, hostname: undefined, protocol: undefined, @@ -706,7 +705,7 @@ function initAsClient(websocket, address, protocols, options) { const protocolSet = new Set(); let perMessageDeflate; - opts.createConnection = isSecure ? tlsConnect : netConnect; + opts.createConnection = opts.createConnection ?? (isSecure ? tlsConnect : netConnect); opts.defaultPort = opts.defaultPort || defaultPort; opts.port = parsedUrl.port || defaultPort; opts.host = parsedUrl.hostname.startsWith('[')