Search code examples
javagetstream-io

Rate limiting detection using Stream Java API client


The Stream documentation https://getstream.io/docs/#rate-limiting mentions that

you will need to review responses from Stream to watch for error conditions indicating that your API request was rate-limited and retry

I'm using the Stream Java API client. What error conditions do I need to check in order to determine if my API request was rate limited?

Is it an attribute in StreamClientException that I need to check?


Solution

  • There's indeed an attribute of StreamClientException which contains the returning HTTP status code (i.e. just invoke the method getHttpStatusCode()) however, in this case, it won't help since the error code is not propagated.

    Thanks to your reporting, we've fixed the exception handling to raise the HTTP status code up and, in particular for your use-case, we've introduced a new exception RateLimitExceededException.