ExtropyIO / defi-bot

Tutorial for building DeFi arbitrage bots
1.18k stars 467 forks source link

gateway error #7

Closed cipherzzz closed 3 years ago

cipherzzz commented 3 years ago

I'm running the bot in an ubuntu ec2 instance and when it finds an opportunity and attempts a trade I get:

Error: Invalid JSON RPC response: "<html>\r\n<head><title>504 Gateway Time-out</title></head>\r\n<body>\r\n<center><h1>504 Gateway Time-out</h1></center>\r\n<hr><center>Microsoft-Azure-Application-Gateway/v2</center>\r\n</body>\r\n</html>\r\n"

Am I needing to open up ports on my security group on my ec2 instance or something?

More of the stack trace:

Fetching market data @ 2021-01-26T12:59:11-06:00 ...

Profitable?  Asset Order      Exchange Order  Input                   Output                  Profit                  Timestamp                
-----------  ---------------  --------------  ----------------------  ----------------------  ----------------------  -------------------------
true         WETH, DAI, WETH  ZRX, 1Split     1                       1.033573150904851463    0.033573150904851456    2021-01-26T12:59:12-06:00

Error playing sound!
Fetching market data @ 2021-01-26T12:59:14-06:00 ...

(node:17917) UnhandledPromiseRejectionWarning: Error: Invalid JSON RPC response: "<html>\r\n<head><title>504 Gateway Time-out</title></head>\r\n<body>\r\n<center><h1>504 Gateway Time-out</h1></center>\r\n<hr><center>Microsoft-Azure-Application-Gateway/v2</center>\r\n</body>\r\n</html>\r\n"
    at Object.InvalidResponse (/home/ec2-user/environment/projects/defi-advanced-bot/node_modules/web3-core-helpers/lib/errors.js:43:16)
    at XMLHttpRequest.request.onreadystatechange (/home/ec2-user/environment/projects/defi-advanced-bot/node_modules/web3-providers-http/lib/index.js:95:32)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/ec2-user/environment/projects/defi-advanced-bot/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/home/ec2-user/environment/projects/defi-advanced-bot/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpResponseEnd (/home/ec2-user/environment/projects/defi-advanced-bot/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
    at IncomingMessage.<anonymous> (/home/ec2-user/environment/projects/defi-advanced-bot/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
cipherzzz commented 3 years ago

I'm guessing that this has to do with 0x throttling the api calls in

const zrxResponse = await axios.get(`https://api.0x.org/sra/v3/orderbook?baseAssetData=0xf47261b0000000000000000000000000${baseAssetAddress}&quoteAssetData=0xf47261b0000000000000000000000000${quoteAssetAddress}&perPage=1000`)

It seems like trades are executing though so closing this.

angelassets commented 3 years ago

I get this same error, but the bot hangs immediately afer that:

Error playing sound! Fetching market data @...