Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WS clientConfig types and clarify docs #3563

Closed
cgewecke opened this issue Jun 3, 2020 · 0 comments · Fixed by #3566
Closed

Fix WS clientConfig types and clarify docs #3563

cgewecke opened this issue Jun 3, 2020 · 0 comments · Fixed by #3566
Assignees
Labels
1.x 1.0 related issues Documentation Relates to project wiki or documentation Types Incorrect or missing types
Projects

Comments

@cgewecke
Copy link
Collaborator

cgewecke commented Jun 3, 2020

In #1354 @naddison36 reports that the types and documentation for part of the WebsocketProvider client config that enables a long running connection to Infura are incorrect.

copied comment


For future devs looking for a solution to keeping a WebSocket connection to Infura alive, this worked for me

const provider = new Web3.providers.WebsocketProvider(
            config.PROVIDER_WS,
            {
                // @ts-ignore
                clientConfig: {
                    keepalive: true,
                    keepaliveInterval: 60000
                }
            }
        );

@ts-ignore is required for TypeScript as the Web3js typings is expecting a string for the clientConfig option which is wrong. The doco for the WebSocketClient used by Web3js also does not properly cover the keepalive config. https://github.com/theturtle32/WebSocket-Node/blob/master/docs/WebSocketClient.md#client-config-options

The WebSocketConnection code with the keepalive config is at https://github.com/theturtle32/WebSocket-Node/blob/574b703ca978709832c6c2f67d6c1de376d432b5/lib/WebSocketConnection.js#L111

@cgewecke cgewecke added Documentation Relates to project wiki or documentation Types Incorrect or missing types 1.x 1.0 related issues labels Jun 3, 2020
@ryanio ryanio added this to To do in v1.2.10 Jun 3, 2020
@ryanio ryanio self-assigned this Jun 3, 2020
@ryanio ryanio moved this from To do to In review in v1.2.10 Jun 3, 2020
@ryanio ryanio moved this from In review to Done in v1.2.10 Jun 6, 2020
@ryanio ryanio mentioned this issue Jul 9, 2020
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues Documentation Relates to project wiki or documentation Types Incorrect or missing types
Projects
No open projects
v1.2.10
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants