Esockettimedout error

Am getting ESOCKETTIMEDOUT Error when I try to connect to Rinkeby or ropsten from my local truffle project. How do I resolve this?

hi @VictorOmbui and welcome to the community !
Can you please post the full error response you’re getting ?
Also, would help to see the network configuration in the truffle-config.js file.

Thanks,
Traian

$ truffle migrate --network rinkeby --reset

Compiling your contracts…

Everything is up to date, there is nothing to compile.

Starting migrations…

Network name: ‘rinkeby’
Network id: 4
Block gas limit: 10000000 (0x989680)

1_initial_migration.js

Deploying ‘Migrations’

transaction hash: 0xf7a50a5b383281f7f1455ba390dfb5fc46ff3e417f1fd45c42ebeb973ede4cf9
Blocks: 2 Seconds: 21
contract address: 0x23069c8cf3eBcf469815630092B3EDd66EcDbE66
block number: 8257549
block timestamp: 1616096468
account: 0x8C9ad9Ff0655Db057317FDd37B4aabcC5411E87D
balance: 1.9490907206
gas used: 220035 (0x35b83)
gas price: 20 gwei
value sent: 0 ETH
total cost: 0.0044007 ETH

Saving migration to chain.
Saving artifacts


Total cost: 0.0044007 ETH

2_random_number_consumer.js

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({
code: -32603,
message: ‘ESOCKETTIMEDOUT’,
data: { originalError: { code: ‘ESOCKETTIMEDOUT’, connect: false } },
stack: ‘Error: ESOCKETTIMEDOUT\n’ +
’ at ClientRequest. (D:\ETH\dynamic nft creation - code-along\node_modules\request\request.js:816:19)\n’ +
’ at Object.onceWrapper (events.js:420:28)\n’ +
’ at ClientRequest.emit (events.js:314:20)\n’ +
’ at TLSSocket.emitRequestTimeout (_http_client.js:716:9)\n’ +
’ at Object.onceWrapper (events.js:420:28)\n’ +
’ at TLSSocket.emit (events.js:326:22)\n’ +
’ at TLSSocket.Socket._onTimeout (net.js:484:8)\n’ +
’ at listOnTimeout (internal/timers.js:554:17)\n’ +
’ at processTimers (internal/timers.js:497:7)’
})
at Web3ProviderEngine.emit (events.js:303:17)
at D:\ETH\dynamic nft creation - code-along\node_modules@trufflesuite\web3-provider-engine\index.js:57:14
at afterRequest (D:\ETH\dynamic nft creation - code-along\node_modules@trufflesuite\web3-provider-engine\index.js:151:21)
at D:\ETH\dynamic nft creation - code-along\node_modules@trufflesuite\web3-provider-engine\index.js:176:21
at D:\ETH\dynamic nft creation - code-along\node_modules@trufflesuite\web3-provider-engine\index.js:238:9
at D:\ETH\dynamic nft creation - code-along\node_modules\async\internal\once.js:12:16
at replenish (D:\ETH\dynamic nft creation - code-along\node_modules\async\internal\eachOfLimit.js:61:25)
at D:\ETH\dynamic nft creation - code-along\node_modules\async\internal\eachOfLimit.js:71:9
at eachLimit (D:\ETH\dynamic nft creation - code-along\node_modules\async\eachLimit.js:43:36)
at D:\ETH\dynamic nft creation - code-along\node_modules\async\internal\doLimit.js:9:16
at end (D:\ETH\dynamic nft creation - code-along\node_modules@trufflesuite\web3-provider-engine\index.js:217:5)
at Request._callback (D:\ETH\dynamic nft creation - code-along\node_modules@trufflesuite\web3-provider-engine\subproviders\rpc.js:36:21)
at self.callback (D:\ETH\dynamic nft creation - code-along\node_modules\request\request.js:185:22)
at Request.emit (events.js:314:20)
at ClientRequest. (D:\ETH\dynamic nft creation - code-along\node_modules\request\request.js:819:16)
at Object.onceWrapper (events.js:420:28)
at ClientRequest.emit (events.js:314:20)
at TLSSocket.emitRequestTimeout (_http_client.js:716:9)
at Object.onceWrapper (events.js:420:28)
at TLSSocket.emit (events.js:326:22)
at TLSSocket.Socket._onTimeout (net.js:484:8)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)

Try to add networkCheckTimeout and timeoutBlocks parameters into your Rinkeby network settings - see this for reference https://github.com/trufflesuite/truffle/issues/3468

The cause of the error is truffle times out before we deploy, no?
I’ve used the article to update my truffle config. My deployment was still failing with networkCheckTimeout: 1000000 and timeoutBlocks: 200, so I should increase the two values as much as possible?
Am going as high as 100000000 and 20000 and still getting the same error

It’s probably something else. Can you show me how you’ve defined the network in truffle config ?
Also it would be good to try a plain curl to infura and exclude a more general connection issue:

curl https://mainnet.infura.io/v3/<project_id>
-X POST
-H “Content-Type: application/json”
-d ‘{“jsonrpc”:“2.0”,“method”:“eth_blockNumber”,“params”: [],“id”:1}’

rinkeby: {

  provider: () => {

    return new HDWalletProvider(mnemonic, url)

  },

  network_id: 4,

  networkCheckTimeout: 1000000000,

  timeoutBlocks: 200000, 

  skipDryRun: true

},

Not familiar with curl, I can look it up, or if you can share someplace I can read about it I will appreciate

Thanks, I’ll look a bit more into this error.
Here’s the doc about curl: https://curl.se/

It all indicates a timeout on the block polling, can you show me the provider url ? (without the projectid ofc) I’d like to see the format and if it’s ws or https.

Also, try to add the following option too in your truffle network config:

confirmations: 2

Thanks !

https://rinkeby.infura.io/v3/ (I could have replied earlier, but different time zones)

Could truffle be part of the issue? I was being asked to try out hardhat instead

I managed to deploy successfully with hardhat today. I might be using that going forward

Hmm, weird, maybe the Truffle team could help out better with this error: https://www.trufflesuite.com/community

Thanks

1 Like