EatTheBlocks Forum

Profitable Flashloans (BSC): 'connection failed'

So I’ve deployed my bsc contract to the mainnet and when I try to run the run-arbitrage.js, Im getting a connection failed error

My WSS is connected properly to moralis, any ideas?

G:\Dev\ETH Flashloans>node run-arbitrage.js
G:\Dev\ETH Flashloans\node_modules\web3-core-helpers\lib\errors.js:66
        const error = new Error(msg);

Error: connection not open on send()
    at Object.ConnectionError (G:\Dev\ETH Flashloans\node_modules\web3-core-helpers\lib\errors.js:66:23)
    at Object.ConnectionNotOpenError (G:\Dev\ETH Flashloans\node_modules\web3-core-helpers\lib\errors.js:49:21)
    at G:\Dev\ETH Flashloans\node_modules\web3-providers-ws\lib\index.js:155:37
    at Map.forEach (<anonymous>)
    at WebsocketProvider._onClose (G:\Dev\ETH Flashloans\node_modules\web3-providers-ws\lib\index.js:154:27)
    at W3CWebSocket._dispatchEvent [as dispatchEvent] (G:\Dev\ETH Flashloans\node_modules\yaeti\lib\EventTarget.js:115:12)
    at W3CWebSocket.onConnectFailed (G:\Dev\ETH Flashloans\node_modules\websocket\lib\W3CWebSocket.js:219:14)
    at WebSocketClient.<anonymous> (G:\Dev\ETH Flashloans\node_modules\websocket\lib\W3CWebSocket.js:59:25)
    at WebSocketClient.emit (node:events:390:28)
    at WebSocketClient.failHandshake (G:\Dev\ETH Flashloans\node_modules\websocket\lib\WebSocketClient.js:339:10)
    at ClientRequest.<anonymous> (G:\Dev\ETH Flashloans\node_modules\websocket\lib\WebSocketClient.js:278:18)
    at ClientRequest.emit (node:events:390:28)
    at HTTPParser.parserOnIncomingClient (node:_http_client:623:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
    at TLSSocket.socketOnData (node:_http_client:487:22)
    at TLSSocket.emit (node:events:390:28) {
  code: 1006,
  reason: 'connection failed'

I’ve ran the node run-arbitrage.js command again and it started working

1 Like


Very nice. So did you make profits ?


not yet, I’m running into some issues with running the script 24/7 - the api calls to the bscnode is timing out and disconnecting so I need to update the script to auto reconnect

Oh I got it. Do you use a free websocket API provider ? I checked on ANKR but It wasn’t free…

yes i used a free WS provider.
ANKR gave me problems, moralis was good but kept disconnecting.
I thought it was a free service problem and paid for 50m calls on getblock and still getting the disconnection error… so a free service is good enough i think - moralis would be a good choice.

1 Like