diff --git a/packages/web3-providers-ws/src/index.js b/packages/web3-providers-ws/src/index.js index b4ff2fc3dd5..9abfd167a7f 100644 --- a/packages/web3-providers-ws/src/index.js +++ b/packages/web3-providers-ws/src/index.js @@ -79,13 +79,17 @@ var WebsocketProvider = function WebsocketProvider(url, options) { // Allow a custom client configuration var clientConfig = options.clientConfig || undefined; + + // Allow a custom request options + // https://github.com/theturtle32/WebSocket-Node/blob/master/docs/WebSocketClient.md#connectrequesturl-requestedprotocols-origin-headers-requestoptions + var requestOptions = options.requestOptions || undefined; // When all node core implementations that do not have the // WHATWG compatible URL parser go out of service this line can be removed. if (parsedURL.auth) { headers.authorization = 'Basic ' + _btoa(parsedURL.auth); } - this.connection = new Ws(url, protocol, undefined, headers, undefined, clientConfig); + this.connection = new Ws(url, protocol, undefined, headers, requestOptions, clientConfig); this.addDefaultEvents();