dutu / poloLender

Free, open source, high performance bot for lending funds on Poloniex exchange
https://github.com/dutu/poloLender
Other
160 stars 47 forks source link

Too many API calls when deployed on Heroku #6

Closed jkelly99 closed 7 years ago

jkelly99 commented 8 years ago

When deployed on Heroku, following the provided instructions, I get this continuously after starting the app

Sep 28 23:05:55 fast-depths-35755 app/poloLender.1: info: Connected to server safe-hollows.crypto.zone Sep 28 23:06:20 fast-depths-35755 app/poloLender.1: notice: returnOpenLoanOffers: Please do not make more than 6 API calls per second. Sep 28 23:06:39 fast-depths-35755 app/poloLender.1: notice: returnOpenLoanOffers: Please do not make more than 6 API calls per second. Sep 28 23:06:42 fast-depths-35755 app/poloLender.1: notice: returnOpenLoanOffers: Please do not make more than 6 API calls per second. Sep 28 23:06:46 fast-depths-35755 app/poloLender.1: notice: returnOpenLoanOffers: Please do not make more than 6 API calls per second. Sep 28 23:06:50 fast-depths-35755 app/poloLender.1: notice: returnAvailableAccountBalances: Please do not make more than 6 API calls per second.

What might be causing this and how can I resolve it?

Thanks.

dutu commented 8 years ago

@jkelly99, it is not an error and the bot logs it as a notice. It happens because the bot executes to many API calls. It can be ignored. Do you get this message continuously or only from time to time?

dutu commented 8 years ago

The execution can be slowed down by changing the timeout at https://github.com/dutu/poloLender/blob/master/server/workers/poloLender/poloLender.js#L599

If it really happens all the time I can update the timeout; please let me know

jkelly99 commented 8 years ago

Thank you for the response. It does happen continuously. Based on your above suggestion, I increased the timeout from 300 to 600. It did decrease the frequency of the message, but it is still continuous. For now, I decided to just filter out the notification so it doesn't show in the log.

dutu commented 7 years ago

Pololender v0.6.1 has introduced API call throttling to comply with Poloniex limits *max 6 API calls per seconds). Occasionally, Poloniex still returns error 429 "Please do not make more than 6 API calls per second". I sought assistance/explanation from Poloniex support on why the error is still issued and will update with a response shortly.

Nevertheless, Pololender v0.6.1 can now be used, instead of any timer modification.

dutu commented 7 years ago

@jkelly99, Poloniex support has clarified that linked accounts share the API limit. Pololender v0.6.1 has introduced API call throttling to comply with Poloniex limits, however if you have any other apps running towards a linked account, error 429 "Please do not make more than 6 API calls per second" can still occur.

So please run Pololender v0.6.1 (or higher) and consider not running any other app towards a linked account. Alternatively, ignore the error 429 complaining about API limit.

I will close this issue now, if anything else please let me know.

VinnyR commented 7 years ago

Hello,

Sorry I know this issue was closed but I'm getting similar error messages. I'm using poloLender 0.7.0 on heroku:

returnActiveLoans: Poloniex error 429: Please do not make more than 8 API calls per second. returnAvailableAccountBalances: Poloniex error 429: Please do not make more than 8 API calls per second. returnOpenLoanOffers: Poloniex error 429: Please do not make more than 8 API calls per second.

The errors are continuous as you can see in the image below. This wasn't happening before I upgraded from version 0.6.1. I don't have any linked poloniex accounts and I only have one API key that I use for poloLender.

Do I need to worry about this? I'm a bit worried I might get kicked off poloniex for abusing their API.

Many thanks

all_apps_ _papertrail_-_2017-04-07_03 34 41

dutu commented 7 years ago

@VinnyR, would you please set the env variable DEBUG=pololender and send me the console log.

you can do that on heroku dashboard (click Settings and Reveal Config Vars, then add DEBUG as key and pololender as value)

image

dutu commented 7 years ago

Please also make sure you only have one dyno running. the "web" should be running, if you have any other please stop/delete

image

VinnyR commented 7 years ago

Hello,

I only have one dyno in my account. I have attached an image of log and also an excel file with 1000 logs.

Thanks

log.xlsx

all_apps_ _papertrail_-_2017-04-07_20 08 18

dutu commented 7 years ago

@VinnyR , thanks a lot for the logs! out of 1000 log lines over 30minutes I could only see one error 429: Please do not make more than 8 API calls per second, and debug line just before this saying "Calls last second: 7 ".

Nevertheless, I'll check it out and also consult with Poloniex support on where the issue can be. If you get more logs with error 429 about API limit please send them over to me.

VinnyR commented 7 years ago

Hello,

I noticed that I get error 429 on average about every 30 seconds, but sometimes there are gaps of 2-3 minutes. The logs is sent were over a 3 minute period not 30 minutes, so maybe this explains why you can only see one error.

I've attached another spreadsheet with logs over a longer time period. When you open the spreadsheet, you can see that I've split the logs into two separate sheets. One sheet shows about 1.5 hours of logs without DEBUG and the other sheet shows about an hour with DEBUG.

Last night I changed the maxApiCallsPerSecond variable in server\workers\poloLender\poloLender.js which seems to work.

When I set maxApiCallsPerSecond = 5, it reduces the error to every 30 minutes. When I set maxApiCallsPerSecond = 4, I don't get the error at all (it's been going for 12 hours so far without any errors).

I guess I'll leave maxApiCallsPerSecond = 4 until there is a better solution.

(The attached spreadsheet shows logs before I changed maxApiCallsPerSecond. i.e. it shows logs when maxApiCallsPerSecond = 6)

log2.xlsx

dutu commented 7 years ago

It looks that Poloniex does not adhere to the API call limit policy they have. Nevertheless, I updated the timers to slow down the app a little bit and the error should how occur anymore. Please update the app to 0.7.1

VinnyR commented 7 years ago

Thanks, the update has drastically reduced the frequency of the errors, although I still get the error about about every 90 minutes. Personally I don't mind this, I'm just mentioning it in case the feedback is of any use to you.

p.s. I'm really enjoying using your bot. You've done great work!

abletaz commented 7 years ago

I was getting continual errors about too many API calls today both running locally and on Heroku, which disappeared after I switched maxApiCallsPerDuration to 4.

dutu commented 7 years ago

Poloniex was under constant DDOS attacks during the past day. Please wait until Poloniex stabilises and we can re-evaluate. Please give feedback in a day or so. Thank you