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

Couldn't connect to node on WS (using getBlock method at #599275 ropsten) #3388

Closed
rlaace423 opened this issue Feb 23, 2020 · 7 comments
Closed
Labels
1.x 1.0 related issues Documentation Relates to project wiki or documentation

Comments

@rlaace423
Copy link

Expected behavior

fetch block information

Actual behavior

Error with message like
image

Steps to reproduce the behavior

  1. create new web3 object with WebsocketProvider
  2. call getBlock function like below
    web3.eth.getBlock(599275, true);

Logs

Versions

nodejs : v10.16.3
npm : v6.13.2
web3 : v1.2.6
os : ubuntu 16.04

@rlaace423
Copy link
Author

I think in 599275, there's 1077 transactions in it. Is there any way to overcome it?

@cgewecke
Copy link
Collaborator

@rlaace423 Can confirm that Ropsten 599275 is a problem when calling Infura over Websockets with:

await web3.eth.getBlock(599275, true); // "true" means include full tx objects

This looks like it works:

await web3.eth.getBlock(599275); // only include transaction hashes

It also works for full tx objects using an Http provider instead of Websockets.

Are either of those options for you?

@cgewecke cgewecke added the 1.x 1.0 related issues label Feb 24, 2020
@cgewecke cgewecke changed the title Cannot get block with getBlock method at #599275 ropsten Couldn't connect to node on WS (using getBlock method at #599275 ropsten) Feb 24, 2020
@cgewecke
Copy link
Collaborator

@rlaace423 Actually, just got it to work as expected by using a suggestion in this #1217 comment.

It's possible to set the websocket frame size limits larger when instantiating the provider,

const web3 = new Web3(new Web3.providers.WebsocketProvider(
    'wss://ropsten.infura.io/ws/v3/<projectID>',
    {
      clientConfig: {
        maxReceivedFrameSize: 100000000,
        maxReceivedMessageSize: 100000000,
      }
    }
  ));

This needs to be added to the documentation.

@cgewecke cgewecke added the Documentation Relates to project wiki or documentation label Feb 24, 2020
@rlaace423
Copy link
Author

@cgewecke Thank you for your help!

In my situation, I can't handle Web3 constructor because it resides in 3rd party library (https://github.com/bitpay/bitcore).

Also, I've already tried #1217 (comment), but had no luck.

@cgewecke
Copy link
Collaborator

@rlaace423 I just ran this script and it worked...

index.js

const Web3 = require('web3');
const util = require('util');

async function main(){
  const web3 = new Web3(new Web3.providers.WebsocketProvider(
    'wss://ropsten.infura.io/ws/v3/<infura-project-id>', // <-- Put your projectID here
    {
      clientConfig: {
        maxReceivedFrameSize: 100000000,
        maxReceivedMessageSize: 100000000,
      }
    }
  ));
  const block = await web3.eth.getBlock(599275, true);
  console.log(util.inspect(block))
}

main()
  .then(() => process.exit(0))
  .catch(err => {
    console.log(err);
    process.exit(1)
  });

Run

node ./index.js

Could you double-check that?

I can't handle Web3 constructor because it resides in 3rd party library

Do you mean you can't configure the provider?

@rlaace423
Copy link
Author

I found that I only tested with maxReceivedFrameSize, and I figured out maxReceivedMessageSize must be used together! I works like a charm :)

And, yes, I cannot configure the provider. But I can pull-request this.

Thank you!

@cgewecke
Copy link
Collaborator

cgewecke commented Mar 3, 2020

@rlaace423 I'm going to track the documentation need raised here via PR 3402 if that's ok with you.

Please just ping if you'd like this re-opened / think more should be done here.

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
Projects
None yet
Development

No branches or pull requests

2 participants