1

I have just finished the CryptoZombies tutorials, and was trying to deploy the file following their instructions to the Rinkeby network. But I keep getting this timeout error and am lost on how to proceed.

$truffle migrate --network rinkeby

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.


/usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/index.js:56
        throw new Error(errorMessage);
^
Error: There was a timeout while attempting to connect to the network.
       Check to see that your provider is valid.
       If you have a slow internet connection, try configuring a longer timeout in your Truffle config. Use the networks[networkName].networkCheckTimeout property to do this.
    at Timeout._onTimeout (/usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/index.js:56:1)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)

My truffle-config.js is as follows:

const HDWalletProvider = require("truffle-hdwallet-provider");

const mnemonic = "depth invite butter ...";

module.exports = {

  networks: {

    mainnet: {
      provider: function () {

        return new HDWalletProvider(mnemonic, "https://mainnet.infura.io/v3/YOUR_TOKEN")
      },
      network_id: "1"
    },

    rinkeby: {

      provider: function () {

        return new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/v3/YOUR_TOKEN")
      },

      network_id: 4
    }
  }
}; 
2
  • 1
    And YOUR_TOKEN is your Infura project ID? Apr 22, 2020 at 11:50
  • unfortunately not. had to leave some dumb thing! Thanks.
    – srinivas
    Apr 22, 2020 at 11:59

4 Answers 4

7

I have fixed this problem by setting networkCheckTimeout as 10000 before setting provider in truffle-config.js.

networks: {
  bsctest: {
      networkCheckTimeout: 10000, 
      provider: () => new HDWalletProvider(mnemonic, `https://data-seed-prebsc-1-s1.binance.org:8545/`),
      network_id: 97,
      confirmations: 10,
      timeoutBlocks: 2000,
      skipDryRun: true
    }
}
1

It's important to keep coolness of mind while learning the blockchain development complexities and connections.

In this case it was not clear from the tutorials I was following, but to actually deploy to any of the networks, you need to create a project id/token.

In this case as I was trying to deploy to the Rinkeby test network by Infura.io --> I had to go to the website and create and account and then create a project, and the project key/id which I replaced in my truffle config and lo and behold! it works now.

1
  • Just wanted to +1 this. Sorted my issue out when using hotspot / internet cafes with TESTNET (which was driving me CRAZY) Feb 13 at 2:18
0

you also can adjust timeout in HDWalletProvider configuration! this fixed an issue for me example

0

I searched for more than a week. Finally, I found the answer here, Not only change the pollingInterval, but also do this: in the module web3-provider-engine, modify the timeout a bigger number. Remember that, the module maybe imported more than one times, so change the value everywhere in your projects.

xhr({
    uri: targetUrl,
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(newPayload),
    rejectUnauthorized: false,
    timeout: 2000,  // change the value bigger

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.