Web3js Http/Ws advanced configuration (Error: socket hang up)

Viewed 29

I have a private network compatible with EVM, some smart contracts deployed on it and an API that provides endpoints to interact with the contract (to make it easier to use for people without Blockchain knowledge).

This API is written with NodeJs and Express. I use web3js 1.7.3 and I have configured my connection to the node as follows:

try {
        provider = new HDWalletProvider({
            mnemonic: {
                phrase: process.env.MNEMONICPHRASE
            },
            providerOrUrl: "http://172.50.20.44:8545"
        });
    } catch (error) {
        console.log(error);
    }

    var options = {
        keepAlive: true,
        withCredentials: false,
        timeout: 20000, // ms
    };

    try {
        web3 = await new Web3(provider, options);
        //console.log(web3);
    } catch (error) {
        console.log(error);
    }

The problem is, if I receive a number of requests let's say >500, it jumps an error:

{
Error: socket hang up
  "originalError": {
    code: "ECONNRESET" { "code": "ECONNRESET"
  }
}

My question is: Is it normal that it does not support so many requests? Can I do some configuration to avoid this?

Because of this problem I lose transactions.

0 Answers
Related