From 076fd46bf13e87458d734c1161a460b24be67aeb Mon Sep 17 00:00:00 2001 From: Ryan Ghods Date: Fri, 5 Jun 2020 17:38:47 -0700 Subject: [PATCH] Fix WS clientConfig types and clarify docs (#3566) --- docs/include_package-core.rst | 6 +++++- packages/web3-core-helpers/types/index.d.ts | 2 +- packages/web3-providers-ws/README.md | 12 +++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/include_package-core.rst b/docs/include_package-core.rst index 2993d84aed4..9cc0e9bc8c1 100644 --- a/docs/include_package-core.rst +++ b/docs/include_package-core.rst @@ -146,10 +146,14 @@ Configuration authorization: 'Basic username:password' }, - // Useful if requests result are large clientConfig: { + // Useful if requests are large maxReceivedFrameSize: 100000000, // bytes - default: 1MiB maxReceivedMessageSize: 100000000, // bytes - default: 8MiB + + // Useful to keep a connection alive + keepalive: true, + keepaliveInterval: 60000 // ms }, // Enable auto reconnection diff --git a/packages/web3-core-helpers/types/index.d.ts b/packages/web3-core-helpers/types/index.d.ts index 2995efba578..0d3a2d66c4e 100644 --- a/packages/web3-core-helpers/types/index.d.ts +++ b/packages/web3-core-helpers/types/index.d.ts @@ -188,7 +188,7 @@ export interface WebsocketProviderOptions { reconnectDelay?: number; headers?: any; protocol?: string; - clientConfig?: string; + clientConfig?: object; requestOptions?: any; origin?: string; reconnect?: ReconnectOptions; diff --git a/packages/web3-providers-ws/README.md b/packages/web3-providers-ws/README.md index a0f2af6f336..b84c32b864c 100644 --- a/packages/web3-providers-ws/README.md +++ b/packages/web3-providers-ws/README.md @@ -41,10 +41,14 @@ var options = { authorization: 'Basic username:password' }, - // Useful if requests are large clientConfig: { + // Useful if requests are large maxReceivedFrameSize: 100000000, // bytes - default: 1MiB maxReceivedMessageSize: 100000000, // bytes - default: 8MiB + + // Useful to keep a connection alive + keepalive: true, + keepaliveInterval: 60000 // ms }, // Enable auto reconnection @@ -57,12 +61,10 @@ var options = { }; var ws = new Web3WsProvider('ws://localhost:8546', options); - -(Additional client config options can be found [here][1]) - -[1]: https://github.com/web3-js/WebSocket-Node/blob/polyfill/globalThis/docs/WebSocketClient.md ``` +Additional client config options can be found [here](https://github.com/theturtle32/WebSocket-Node/blob/v1.0.31/docs/WebSocketClient.md#client-config-options). + ## Types All the TypeScript typings are placed in the `types` folder.