yuyasugano / pancake-bakery-arbitrage

A sample application invokes a flashswap in PancakeSwap and a monitoring tool in Node.js.
304 stars 194 forks source link

Cannot establish websocket connection with web3 #9

Closed coinster closed 2 years ago

coinster commented 2 years ago

Hi,

I think this is not the issue with the code but I'm struggling to get it up and running due to following error and maybe you can help me solve the problem I'm facing.

Error: connection not open on send() at Object.ConnectionError (/pancake-ape-bakery/node_modules/web3-core-helpers/lib/errors.js:66:23) at Object.ConnectionNotOpenError (/pancake-ape-bakery/node_modules/web3-core-helpers/lib/errors.js:49:21) at /pancake-ape-bakery/node_modules/web3-providers-ws/lib/index.js:155:37 at Map.forEach (<anonymous>) at WebsocketProvider._onClose (/pancake-ape-bakery/node_modules/web3-providers-ws/lib/index.js:154:27) at W3CWebSocket._dispatchEvent [as dispatchEvent] (/pancake-ape-bakery/node_modules/yaeti/lib/EventTarget.js:115:12) at W3CWebSocket.onConnectFailed (/pancake-ape-bakery/node_modules/websocket/lib/W3CWebSocket.js:219:14) at WebSocketClient.<anonymous> (/pancake-ape-bakery/node_modules/websocket/lib/W3CWebSocket.js:59:25) at WebSocketClient.emit (events.js:375:28) at WebSocketClient.failHandshake (/pancake-ape-bakery/node_modules/websocket/lib/WebSocketClient.js:339:10) at ClientRequest.<anonymous> (/pancake-ape-bakery/node_modules/websocket/lib/WebSocketClient.js:278:18) at ClientRequest.emit (events.js:375:28) at HTTPParser.parserOnIncomingClient (_http_client.js:647:27) at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17) at Socket.socketOnData (_http_client.js:515:22) at Socket.emit (events.js:375:28) { code: 1006, reason: 'connection failed' }

I went twice over steps for installing but same issue websocket connection fail here

"let subscription = web3.eth.subscribe('newBlockHeaders', (error, result) => {"

yuyasugano commented 2 years ago

@coinster It is because of either 1) the endpoint that you're using is outdated and not supported or 2) your environment is failing to establish a connection to the websocket endpoint due to network issue. If the endpoint is not supported anymore, you can search public service provider such as Moralis(https://moralis.io/). As it is mentioned in disclaimer the endpoint might be depreciated, and please note that the related article and this repository are just only informational and educational purpose only. I'll close this case for now. Thanks!!

The codes are written for informational and educational purpose only, https and websocket endpoints might not work well if those endpoint have been depreciated. Please find other available endpoints in that case. Thanks for your understanding.