Hi to all, i get this error normally and i dont understand what i need to do.
I´m using moralis socket url to connect web3 and HDWalletProvider. The reason is that i need to comunicate to smart contract in bsc and i want to do with an existing wallet.
This is the code from conecting :
const provider = new Web3.providers.WebsocketProvider(urlMoralisSocket, options);
This is a hack for listen events with HDProvider (I’m getted from here and working https://ethereum.stackexchange.com/questions/103301/the-current-provider-doesnt-support-subscriptions-hdwalletprovider-on-polygon).
HDWalletProvider.prototype.on = provider.on.bind(provider);
let providerHD = new HDWalletProvider(mnemonic, provider);
web3.setProvider(providerHD);
And i use web3 to instanciate contract and interact with him. Using events, call or send methods.
But i get this error:
Error: PollingBlockTracker - encountered an error while attempting to update latest block:
Error: CONNECTION ERROR: Provider started to reconnect before the response got received!
I’m have options in WebsocketProvider using delay on reconnect. This is options value:
{
timeout: 50000,
clientConfig: {
keepalive: true,
keepaliveInterval: 60000,
maxReceivedFrameSize: 2000000, // bytes - default: 1MiB, current: 2MiB
maxReceivedMessageSize: 10000000, // bytes - default: 8MiB, current: 10Mib
},
reconnect: {
auto: true,
delay: 60000,
onTimeout: true,
maxAttempts: 10,
}
}
But if i remove (options) i get this error:
Error: CONNECTION ERROR: The connection got closed with the close code
4040
and the following reason stringDraining connection
code: 4040,
reason: ‘Draining connection’
And
Error: PollingBlockTracker - encountered an error while attempting to update latest block:
Error: CONNECTION ERROR: Couldn’t connect to node on WS.
Thanks and i hope that anyone can help me