惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Project Zero
Project Zero
月光博客
月光博客
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
O
OpenAI News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Know Your Adversary
Know Your Adversary
Last Week in AI
Last Week in AI
S
Securelist
Engineering at Meta
Engineering at Meta
博客园 - 司徒正美
P
Privacy & Cybersecurity Law Blog
T
Tailwind CSS Blog
F
Fortinet All Blogs
博客园 - 三生石上(FineUI控件)
Scott Helme
Scott Helme
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
小众软件
小众软件
U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
Hacker News: Ask HN
Hacker News: Ask HN
Hugging Face - Blog
Hugging Face - Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
SecWiki News
SecWiki News
宝玉的分享
宝玉的分享
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
Lohrmann on Cybersecurity
IT之家
IT之家
Security Archives - TechRepublic
Security Archives - TechRepublic
I
InfoQ
S
Security @ Cisco Blogs
Webroot Blog
Webroot Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
Cyberwarzone
Cyberwarzone
人人都是产品经理
人人都是产品经理
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
B
Blog RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - softfair

在Windows平台编译Substrate (How to compile and run Substrate on Windows) Rust 里 String,str,Vec<u8>,Vec<char> 相互转换【Conversion between String, str, Vec<u8>, Vec<char> in Rust】 Linux下一个最简单的不依赖第三库的的C程序(2) Linux下一个最简单的不依赖第三库的的C程序(1) windbg .net 程序的死锁检测 常用方法(个人备份笔记) 自定义经纬度索引(非RTree、Morton Code[z order curve]、Geohash的方式) 通过经纬度坐标计算距离的方法(经纬度距离计算) 根据2个经纬度点,计算这2个经纬度点之间的距离(通过经度纬度得到距离) The version of SOS does not match the version of CLR you are debugging; SOS.dll版本不匹配; Dump文件不同环境mscordacwks.dll版本问题 WCF 4.0 如何编程修改wcf配置,不使用web.config静态配置 WCF4.0安装 NET.TCP启用及常见问题 Windbg 脚本命令简介 二, Windbg command Windbg 脚本命令简介 一 what’s new in the .NET CLR 4.0/4.5 GC (.NET 4/4.5里新的垃圾收集机制) Windows中内存管理的一些知识 SSO(Single Sign-on) in Action 阿里巴巴将跌破1元股价 word 2007 中插入图片无法显示,只能显示底部一部分 Linux 动态库剖析
Truffle migrate deploy contract ESOCKETTIMEDOUT - How to fix
softfair · 2022-05-01 · via 博客园 - softfair

使用Truffle 来部署NTF项目的时候,很多时候,合约比较大,部署计较耗时,很容易出现超时。

人们常见的提问:

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

ESOCKETTIMEDOUT ERROR while trying to deploy to Rinkeby

truffle migrate --network rinkeby Time Out # Error: PollingBlockTracker - encountered an error while attempting to update latest block:

truffle migrate timeout error

常见的报错:

Error: Unhandled error. ({
  code: -32603,
  message: 'ESOCKETTIMEDOUT',
  data: { originalError: { code: 'ESOCKETTIMEDOUT', connect: false } }
})
    at new NodeError (node:internal/errors:371:5)
    at Web3ProviderEngine.emit (node:events:509:17)
    at ..../node_modules/web3-provider-engine/index.js:54:14
    at afterRequest (..../node_modules/web3-provider-engine/index.js:148:21)
    at ..../node_modules/web3-provider-engine/index.js:174:21
    at ..../node_modules/web3-provider-engine/index.js:232:9
    at ..../node_modules/async/internal/once.js:12:16
    at replenish (..../node_modules/async/internal/eachOfLimit.js:61:25)
    at ..../node_modules/async/internal/eachOfLimit.js:71:9
    at eachLimit (..../node_modules/async/eachLimit.js:43:36)
    at ..../node_modules/async/internal/doLimit.js:9:16
    at end (..../node_modules/web3-provider-engine/index.js:211:5)
    at Request._callback (..../node_modules/web3-provider-engine/subproviders/rpc.js:36:21)  // check your callstack
    at self.callback (..../node_modules/request/request.js:185:22)
    at Request.emit (node:events:520:28)
    at ClientRequest.<anonymous> (..../node_modules/request/request.js:820:16)

另外一种报错:

/....../node_modules/eth-block-tracker/src/polling.js:53
        const newErr = new Error(`PollingBlockTracker - encountered an error while attempting to update latest block:\n${err.stack}`)
                       ^
Error: PollingBlockTracker - encountered an error while attempting to update latest block:
undefined
    at PollingBlockTracker._performSync (/......./node_modules/eth-block-tracker/src/polling.js:53:24)
    at runMicrotasks (<anonymous>)

还有一种报错:

Error: Unhandled error. ({
  code: -32603,
  message: 'ESOCKETTIMEDOUT',
  data: { originalError: { code: 'ESOCKETTIMEDOUT', connect: false } }
})
    at new NodeError (node:internal/errors:371:5)
    at Web3ProviderEngine.emit (node:events:509:17)
    at /..../node_modules/@truffle/hdwallet-provider/node_modules/web3-provider-engine/index.js:54:14
    at afterRequest (/..../node_modules/@truffle/hdwallet-provider/node_modules/web3-provider-engine/index.js:148:21)
    at /..../node_modules/@truffle/hdwallet-provider/node_modules/web3-provider-engine/index.js:174:21
    at /..../node_modules/@truffle/hdwallet-provider/node_modules/web3-provider-engine/index.js:232:9
    at /..../node_modules/async/internal/once.js:12:16
    at replenish (/..../node_modules/async/internal/eachOfLimit.js:61:25)
    at /..../node_modules/async/internal/eachOfLimit.js:71:9
    at eachLimit (/..../node_modules/async/eachLimit.js:43:36)
    at /..../node_modules/async/internal/doLimit.js:9:16
    at end (/..../node_modules/@truffle/hdwallet-provider/node_modules/web3-provider-engine/index.js:211:5)
    at Request._callback (/..../node_modules/@truffle/hdwallet-provider/node_modules/web3-provider-engine/subproviders/rpc.js:36:21)   // check your callstack
    at self.callback (/..../node_modules/request/request.js:185:22)
    at Request.emit (node:events:520:28)
    at ClientRequest.<anonymous> (/..../node_modules/request/request.js:819:16)

常见的解决方案:
在 truffle-config.js中加入pollingIntervalnetworkCheckTimeouttimeoutBlocks

ccmtest: {
      provider: () => new HDWalletProvider(privateKey, `http://127.0.0.1:9934`),
      networkCheckTimeout: 10000000,
      pollingInterval:30000,      
      network_id: 1,       
      // gas: 5500000,        
      confirmations: 0,    
      timeoutBlocks: 2000,  
      skipDryRun: true     
    },

但 这里几个参数解决的报错是:

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.

有时候,并不能解决最上面遇到到的错误。

实际需要修改代码超时的地方是在web3-provider-engine 这个模块。在代码 web3-provider-engine/subproviders/rpc.jsxhr默认的超时时间是 timeout: 20000,把它改大。

xhr({
    uri: targetUrl,
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(newPayload),
    rejectUnauthorized: false,
    timeout: 20000,     //change this  config
  }, function(err, res, body) {

查看报错的堆栈
常见有几处地方:

  1. Truffle 使用的hdwallet-provider模块下有web3-provider-engine
    .../node_modules/@truffle/hdwallet-provider/node_modules/web3-provider-engine/subproviders/rpc.js
  2. 直接引用的web3-provider-engine
    .../node_modules/web3-provider-engine/subproviders/rpc.js:36:21

找到他们都把他们改掉。ESOCKETTIMEDOUT 问题就能解决。

参考:https://juejin.cn/post/6865562790778634253