Answer the question
In order to leave comments, you need to log in
VK API rejects requests at random, citing high frequency. How to decide?
Good afternoon. The VK API is freaking out like no one has ever freaked out before... The documentation says that the frequency limit is 3 requests per second. I write in Node.JS. Created a function and a package of variables to control the frequency of access using setTimeout, count and the like. All timestamps, namely in events: (beforeSend, response), indicate that requests are made EXACTLY no more than 3 pieces in 1000 ms, and sometimes even longer. But VK, starting from 10 requests out of 30, gives an error Too many requests per second (Error code: 6). Brad has already begun. Ok, I decided to check how it works "manually".
I wrote the send() function inside which is just a request function with a callback and so on. Called send 9 times in a row (internal measurements show that this case was sent once every 1 ms) NOT A SINGLE ERROR, everything is fine with the VK API. Ok, I decided to find out the limit - it is equal to 9... On the 10th request, VK starts to give out the same error.
Where. Here. Logics?! I already understood that the VK API was done by the crooked, in terms of the frequency of returning errors (in the morning, afternoon, evening, 3 errors in polling crashes 100%) 501 502 with the text "Internal server error: Unknown error, try later", "connect ECONNREFUSED", "Error: socket hang up". Simply put, in the history of working with VK Api, the latter had fun as best he could, in a variety of ways. But in order to completely contradict the documentation in the absence of logic, in principle, as such, this is overkill.
Who can tell me what to do in such a situation, or was I angry in vain and in fact I stepped terribly?
Answer the question
In order to leave comments, you need to log in
VK either fixed this case, or I don’t know what. Now the same code works great. 3 requests always go smoothly.
Do you take into account the processing time of the request and delivery, or do you count only the starting moments?
Requests have a length. If you finish receiving the answer to any of the three after 1000ms, then only after it ends, you should send the fourth one.
If everything is fast and the answers are accepted, fitting in 1000ms, you need to withstand some minimum gap after 1000ms before the fourth request. For every fireman.
VK API has many different limits, you read the most common one, for more details, the documentation states that for example, for 1 second, one limit, the limits for the 1st hour are NOT equal to the sum of the limits by seconds, etc.
the same applies to individual requests, for example, to send messages (most likely you use it), there are COMPLETELY different limits, although it also works at the beginning of 3 requests per second, but in total, for example, 9 requests per minute (this is conditional, you need to look at the documentation) and eg 30 requests per hour, 100 requests per day.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question