Web3.js: Pass config object to WebSocketClient

Created on 8 Dec 2017  路  5Comments  路  Source: ChainSafe/web3.js

I'm trying to get a payload of 22meg from the blockchain but I get the exception Frame size of 21980028 bytes exceeds maximum accepted frame size

The maxReceivedFrameSize and maxReceivedMessageSize are set in the websocket client class. If these are increased the code works fine.

Could a config object be passed to Ws when its instantiated in web3-providers-ws?

enhancement

Most helpful comment

This is fixed in beta.36 but the setting is clientConfig

js web3s = new Web3(new Web3.providers.WebsocketProvider("ws://localhost:8546", { clientConfig: { maxReceivedFrameSize: 100000000, maxReceivedMessageSize: 100000000, } }));

All 5 comments

I need this too, I want to do something like:

web3s = new Web3(new Web3.providers.WebsocketProvider({
    httpServer: "ws://localhost:8546",
    maxReceivedFrameSize: 100000000,
    maxReceivedMessageSize: 100000000,
}));

Any solution not requiring me to edit and commit the websockets package?

Not yet, we ended up overriding the WebSocketClient.js file in /node_modules_override, which is not ideal.

Is there still no option for this? I cant use the beta with web sockets, every call exceeds max frame size.

It looks like https://github.com/ethereum/web3.js/pull/1631 added a fix for this which should allow doing

web3s = new Web3(new Web3.providers.WebsocketProvider("ws://localhost:8546", {
  clientOptions: {
    maxReceivedFrameSize: 100000000,
    maxReceivedMessageSize: 100000000,
  }
}));

It is available in [email protected] and later.

This is fixed in beta.36 but the setting is clientConfig

js web3s = new Web3(new Web3.providers.WebsocketProvider("ws://localhost:8546", { clientConfig: { maxReceivedFrameSize: 100000000, maxReceivedMessageSize: 100000000, } }));

Was this page helpful?
0 / 5 - 0 ratings