Handle rate limiting errors when using a proxy for all requests to the map service

2214
2
05-15-2017 11:02 AM
YohanBienvenue
Occasional Contributor II

Hi,

Following some script bot data mining abuse of our map services recently, we now use a proxy to throttle requests to our map services. We are using the Java version of the resource-proxy.

It works fine so far, all ArcGIS requests now go through the proxy and we enabled a few security features in the proxy configuration including rate limiting (throttling).

I modified the proxy so that only "query" requests are throttled. This way the map rendering is not affected for actual human users and it protects us against data mining by scripts. When a query request is rejected because of throttling, the response has HTTP status code 429 (too many requests).

In rare cases where a human user exceeds the number of allowed requests set by the proxy, I was wondering if it's possible (using the error handler of the queryTask in the ArcGIS API) to know the status code of the query failure. For instance if it's 429 I would display a different message to the human user in our GUI.

I parsed through the error object returned by the error handler of QueryTask, but I haven't found anything so far.

Many thanks,

Yohan

0 Kudos
2 Replies
ThomasSolow
Occasional Contributor III

Just curious, but what response do requests get right now when they don't get past the proxy?

It seems to me that if the proxy is not passing through some requests to ArcGIS server, then the proxy is also responsible for responding with the appropriate code.  Or maybe I'm misunderstanding how this is set up.

I don't know anything about resource-proxy, but you could make an issue on github asking this question.  The repo looks reasonably active so I'd imagine someone there can help you out.

0 Kudos
YohanBienvenue
Occasional Contributor II

The proxy returns the following json content:

{

   error: {

      code: 429,

      details: [ "This is a metered resource, number of requests have exceeded the rate limit interval." ],

      message: "Error 429 - Too Many Requests"

    }

}

The ArcGIS JavaScript API does trigger the error callback of the queryTask, but I cannot find this json content anywhere in the error object returned. Ok yeah, perhaps this error format is just not compatible with what the API expects. I'll verify this with resource-proxy.

Thanks Thomas.

0 Kudos