jklepatch / eattheblocks

Source code for Eat The Blocks, a screencast for Ethereum Dapp Developers
https://eattheblocks.com
4k stars 3.2k forks source link

第12课。连接不到infura。报错1006 #212

Open guhexuan opened 1 year ago

guhexuan commented 1 year ago

[请问这该如何解决

C:\Windows\System32\profitable-flashloans>node run-arbitrage.js Error: connection not open on send() at Object.ConnectionError (C:\Windows\System32\profitable-flashloans\node_modules\web3-core-helpers\lib\errors.js:66:23) at Object.ConnectionNotOpenError (C:\Windows\System32\profitable-flashloans\node_modules\web3-core-helpers\lib\errors.js:49:21) at C:\Windows\System32\profitable-flashloans\node_modules\web3-providers-ws\lib\index.js:156:37 at Map.forEach () at WebsocketProvider._onConnectFailed (C:\Windows\System32\profitable-flashloans\node_modules\web3-providers-ws\lib\index.js:155:27) at WebSocketClient.emit (node:events:513:28) at WebSocketClient.failHandshake (C:\Windows\System32\profitable-flashloans\node_modules\websocket\lib\WebSocketClient.js:339:10) at ClientRequest. (C:\Windows\System32\profitable-flashloans\node_modules\websocket\lib\WebSocketClient.js:278:18) at ClientRequest.emit (node:events:513:28) at HTTPParser.parserOnIncomingClient (node:_http_client:701:27) at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17) at TLSSocket.socketOnData (node:_http_client:542:22) at TLSSocket.emit (node:events:513:28) at addChunk (node:internal/streams/readable:324:12) at readableAddChunk (node:internal/streams/readable:297:9) at Readable.push (node:internal/streams/readable:234:10) { code: 1006, reason: 'connection failed', description: 'Error: Server responded with a non-101 status: 503 Service Temporarily Unavailable' }

@jklepatch 这是我跟着教学视频写的 require("dotenv").config(); const Web3 = require('web3'); const web3 = new Web3( new Web3.providers.WebsocketProvider(process.env.INFURA_URL) );

web3.eth.subscribe('newBlockHeaders') .on('data', async block => { console.log(New block received. Block # ${block.number}); }) .on('error', error => { console.log(error); });