Skip to content

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

@guhexuan

Description

@guhexuan

[请问这该如何解决

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);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions