openSenseMap icon indicating copy to clipboard operation
openSenseMap copied to clipboard

Too many requests

Open MagTun opened this issue 6 years ago • 7 comments

In short:
I am wondering what is your policy regarding Too Many Requests ?

  1. Is there a maximum Too Many Requests allowed per hour/day/week?
  2. Do you ban IP if you detect Too Many Requests? If yes, for how long?

The long story
I am using the BME680 sensor from Bosch with their library . This sensor/library only allows measurement every 3 seconds or every 5 min. 5 min is too long for my needs so I am left with the 3 seconds intervals.

Each time I retrieve a measurement, I send the data to my box on opensensemap but at this frequency, I get many (many) 429 Too Many Requests.

I don't mind if not all my measurement are saved on opensensemap. If I get 80% it's fine. But I do not want to get banned (even temporarily) from opensensemap if you detect too many Too Many Requests.

I am sending the data as JSON-Array on ingress.opensensemap.org/boxes/:senseBoxId/data (so I've already bundled all the values of a measurement like temperature, pression, humidity... in one request)

MagTun avatar Nov 22 '19 05:11 MagTun

Hi @MagTun

to start, the way you're sending (JSON-Array) is the right way!

The current limit is 15 requests in a 15 minutes window.

If you could change your code to collect measurements and send multiple measurement cycles at once. This would require you to collect the measurement timestamps on your device. Just include these timestamps with the field createdAt in your requests

ubergesundheit avatar Nov 22 '19 11:11 ubergesundheit

The current limit is 15 requests in a 15 minutes window!? How is it possible that I was able to get this (the measurement were sent separately)?

image

MagTun avatar Nov 22 '19 14:11 MagTun

Hi @MagTun

the current limit is 15 requests in one minute.

mpfeil avatar Nov 22 '19 15:11 mpfeil

Ok that makes sense! So that's one every 4 seconds. I just found a way to delay my request so I am not anymore tied to the BME680 timing. Just to satisfy my curiosity : if I make a mistake and send a request every 1 or 2 seconds, do you ban the IP? if yes, for how long?

MagTun avatar Nov 22 '19 15:11 MagTun

Thanks for clarification @mpfeil :) Maybe you could fill us in on how long the IP is being blocked?

ubergesundheit avatar Nov 22 '19 22:11 ubergesundheit

The IP will not be blocked. But all excessive requests will be blocked. Might change this in the future if people abuse this.

umut0 avatar Dec 12 '19 12:12 umut0

We usually send one request per minute but nevertheless sometimes get 429 Too Many Requests. This happens after 502 Bad Gateway or ConnectionRefused, probably because our server tries to resend what it couldn't be send before.

This happens every few days or so. E.g. today 3:22 (Vienna) there was a connection refused and then plenty of 429 Too Many Requests.

Is it possible that there are server issues on your end sometimes refusing a few API requests? (The 429 Too Many Requests is probably only a side-effect, due to retries.)

Issue on our side is https://github.com/ElektraInitiative/opensesame/issues/116

markus2330 avatar Nov 01 '23 14:11 markus2330