BSC Testnet: Truffle Migrate ETIMEDOUT
Asked Answered
P

5

6

I need to deploy my smart contract to BSC Testnet

I always got this :

Error: PollingBlockTracker - encountered an error while attempting to update latest block:
Error: ETIMEDOUT

I tried to change the RPC specified here https://docs.binance.org/smart-chain/developer/rpc.html#rate-limit

All of them, yet still the same.

One thing is, I tried to deploy it to ropsten instead just for fun. And it is success. Is there any problem with BSC Testnet RPC nowadays ?

Here is my snip for truffle-config.js

        testnet: {
            provider: () => new HDWalletProvider(mnemonic, `https://data-seed-prebsc-1-s2.binance.org:8545`),
            network_id: 97, // 3 for ropsten, 97 for bsc test
            confirmations: 2,
            timeoutBlocks: 2000,
            skipDryRun: true,
            networkCheckTimeout: 1000000
        },

I searched, some people use websocket (wss), some change the RPC Url, some add the networkCheckTimeout. I tried all of them (except wss, since I don't see it is provided by BSC Testnet). But nothing work.

Any suggestion ? Thank you

Paulo answered 5/5, 2021 at 6:10 Comment(3)
Not working here tooCamey
hey did you ever figure this out? having the same issue on bsc testnetCorrugate
@TylerJones Not at all. but I did found an alternative. Instead of using truffle, I used remix. It was able to be deployed successfully with same RPC URL If you are not strictly bind to truffle, you could try remix.Paulo
A
2

When I used other endpoints, The issue was fixed. You can try the below endpoints.

BSC RPC Endpoints:

https://data-seed-prebsc-1-s1.binance.org:8545/
https://data-seed-prebsc-2-s1.binance.org:8545/
https://data-seed-prebsc-1-s2.binance.org:8545/
https://data-seed-prebsc-2-s2.binance.org:8545/
https://data-seed-prebsc-1-s3.binance.org:8545/
https://data-seed-prebsc-2-s3.binance.org:8545/
Ankney answered 5/5, 2022 at 11:12 Comment(0)
B
1

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

The timeout value is hardcoded, maybe nowadays most people have very good Internet connection and only a few techs suffering, I tried very hard to find out the answer. After I change this configuration, I never suffer timeout!

Businesswoman answered 31/5, 2022 at 6:26 Comment(0)
P
0

bsc: {
  networkCheckTimeout: 999999,
  provider: () => new HDWalletProvider(mnemonic, `https://data-seed-prebsc-1-s1.binance.org:8545`),
  network_id: 97, // Ropsten's id
  gas: 5500000, // Ropsten has a lower block limit than mainnet
  confirmations: 10, // # of confs to wait between deployments. (default: 0)
  timeoutBlocks: 200, // # of blocks before a deployment times out  (minimum/default: 50)
  skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
},

adding network timeout should help

Prototherian answered 8/11, 2021 at 0:10 Comment(1)
Is the timeout measured in seconds or milliseconds?Laomedon
L
0

The problem is that BSC produces blocks so quickly that it exceeds the default number of blocks Truffle is configured to wait for. You can solve this by adding the networkCheckTimeout and timeoutBlocks fields in your network config:

bsc: {
  networkCheckTimeout: 1000000,
  timeoutBlocks: 200
}
Laomedon answered 7/3, 2022 at 14:41 Comment(0)
T
0

Best way I found to avoid this error is to

truffle compile

manually before migration.

Then, when migrate, to add the --compile-none option.

truffle migrate --network xxx --compile-none
Tramel answered 4/11, 2022 at 22:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.