chrisleekr / binance-trading-bot

Automated Binance trading bot - Trade multiple cryptocurrencies. Buy low/sell high with Grid Trading. Integrated with TradingView technical analysis
MIT License
5k stars 1.09k forks source link

Getting ETIMEDOUT errors, does anyone experience these errors? #61

Closed traian13 closed 3 years ago

traian13 commented 3 years ago

Hello,

First of all I want to congratulate you @chrisleekr for your work. I really like your bot and started using it for 2 weeks now.

I am using 5 pairs with the cron set up every second (default). So each second it makes 3 api calls to binance, get account info, get open orders and get candles. I am experiencing ETIMEDOUT errors each 2-3 minutes after a while. Sometimes I get the errors pretty fast, after a few minutes, sometimes after 30 minutes. Once the errors appear they kind of repeat every 2-3 minutes.

All api's give the ETIMEDOUT so it is not related to one api.

I know that binance could maybe experience issues from time to time but last night I left the bot running and got the errors every 2-3 minutes for 8 hours straight.

I have very good internet connection, fiber optics 500Mbps.

If I add more pairs it seems the errors start to appear faster to the point where the interface does not update for whole minutes. I also increased the cron time to */5 (each 5 secs) and it was better but I still get the errors after a longer time.

I ran the bot on windows and also on mac and it is the same.

My thoughts are that somehow binance blocks the bot? My question is if anyone experienced these errors or is it related to my setup?

I am pasting one example below.

request to https://api.binance.com/api/v3/klines?interval=30m&symbol=ADAUSDT&limit=30 failed, 
reason: connect ETIMEDOUT 52.84.150.39:443```Stack:```FetchError: request to https://api.binance.com/api/v3/klines?interval=30m&symbol=ADAUSDT&limit=30 failed, 
reason: connect ETIMEDOUT 52.84.150.39:443
    at ClientRequest.<anonymous> (/srv/node_modules/node-fetch/index.js:133:11)
    at ClientRequest.emit (events.js:315:20)
    at TLSSocket.socketErrorListener (_http_client.js:469:9)
    at TLSSocket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
chopeta commented 3 years ago

Sorry for jumping in here, but I have some questions and comments from my usage experience.

1) Where do you get crontab? I have a docker deploy on Linux and never saw there's a configurable crontab.

2) How do you manage to see those errors? There are logs? How do you access them?

I am no expert but Binance have a limit of 1200 API requests per minute, you can see a mention of it in #52 - so even doing 3 request per second you should be good to go.

Maybe it's a issue with the tunnel, have you trying disabling it? Please see #32

traian13 commented 3 years ago

Hei @chopeta, yes, saw #32 and #52

  1. There is no crontab, there is a nodejs module that simulates a cron. You need to change this: https://github.com/chrisleekr/binance-trading-bot/blob/4de7391940064f9c987c076dc9181483ac3cdef7/config/default.json#L41 and also change in Mongo db -> collection trailing-trade-common -> field cronTime and restart

  2. The errors are also in logs and on slack. docker logs binance-bot | grep ETIMEDOUT

I don't think it is related to the localtunnel, the errors come from calls to binance api. The localtunnel works ok. Also, I don't think the bot reaches the limit because it just gives a timeout after 2-3 minutes of working ok. If it would reach the limit it would stop working. I think it may be flagged by the ML algorithm but I can't be sure, it may be from my setup. This is why I am asking if someone else encountered this.

Info on Binance limits: https://www.binance.com/en-AU/support/faq/360004492232

chrisleekr commented 3 years ago

@traian13

Hm, doesn't sound like the bot issue. It must be some connection issue between you and Binance API.

Where are you located?

Are you able to run in a cloud server such as DigitalOcean?

chopeta commented 3 years ago

OK, still a lot to learn here... I didn't have Slack notifs enabled... now I see ETIMEDOUT errors as well inside my Slack channel. Only 3 errors so far, so in theory nothing to be worried about. These are the errors:

From the logs I can't see anything (too many info in there), I guess I have to use bunyan for that.

I also had issues when accessing the bot remotely (over a VPN) using a internet connection with a very high latency... other than that it's working good.

@chrisleekr I am curious about the Slack integration, is there a list of msg types that are defined to be sent to Slack? What else can I expect to see inside Slack?

traian13 commented 3 years ago

@chrisleekr Thanks for the reply.

I am located in Buchares/Romania.

I didn't run the bot in cloud yet because I am still testing it. But I have to try in another environment.

chrisleekr commented 3 years ago

@chopeta

If you enable Slack, you will get notifications such as buy/sell order like below:

image

chrisleekr commented 3 years ago

@traian13 Yeah, please try with another environment (or location).

Timeout is happening when you didn't get the response from API within a specific time.

chrisleekr commented 3 years ago

@traian13 if you have no more issue, please close the issue.

traian13 commented 3 years ago

Sorry, I didn't have time to test in another environment. I'll close the issue and let you know if I have updates.

Suniron commented 3 years ago

Sorry, I didn't have time to test in another environment. I'll close the issue and let you know if I have updates.

Did you find a solution?

I have the same issue...