Open adityamertia opened 6 years ago
Are you sending other requests meanwhile? Because the cap is for all the request, not for a single call. And are you sure you are calling every 5s?
Yes there is no other instance running and the checkStatus is called every 5 secs. I still see this issue on and off.
Try to debug, with "console.log("Calls in last minute: " + this.callsInLastMinute)" in line 83 of Bitstamp.js. You should see that increasing by one every 5 seconds, then reset every minute.
The logic is straight forward, as tuloski has explained. I suspect you are calling more then 15 times. However besides debugging you can disable this behaviour by setting "rateLimit" to false in the options you pass the constructor - but this will return in API errors if you make to many calls.
@tuloski @krystianity I have just added this console.log and it helped in reproducing the issue. From the logs its clear that the timer held by node-bitstamp doesn't reset after a minute in one of the cases and hence this issue pops up. Check the log snippet below to verify the counter incrementing even after 1 minute has passed and hence starts throwing error. This however does happen in 1 in 20 iterations. logsnippet.txt
I tried and it resets for me. Which version of nodejs are u using? Is running in a browser?
It does reset for me 19 out of 20 times .... but once in a while it does not ...as seen in the log attached and then it starts giving error. I am using node v9.4.0 running on linux.
I'm not a big fan of setInterval, because they are known to create problems. Try to debug with a console.log also inside the setInterval function. The logic is so easy that it has to be some sneaky thing.
You refering to setInterval inside library? In Bitstamp.js:
// 600 requests max per 10 minutes
const MAX_CALL_WINDOW = 60 * 1000; // 10 minutes
const MAX_CALLS_PER_WINDOW = 60;
this._intv = setInterval(() => {
this.callsInLastMinute = 0;
}, MAX_CALL_WINDOW);
Yeah...that should reset the calls per minute every minute.
Hi, Whenever i check for an orders status using
await bitstamp.orderStatus(orderId).then(({status, headers, body}) => body);
I keep getting following error even if i run it at 5 sec intervals:Its run 15 times in 60000ms still i get this error. what could be wrong here?