sprinklr-inc/twitter4j-ads

503 OVER_CAPACITY Retry-After header

Closed this issue · 2 comments

We're seeing a lot of HTTP 503 (SERVICE_UNAVAILABLE) errors lately and came across the following which seems to indicate that the Retry-After header is set when this occurs.

https://twittercommunity.com/t/announcement-503-over-capacity-responses/50863

However, TwitterException.getRetryAfter() doesn't seem to try to parse that header value when a SERVICE_UNAVAILABLE response is received:

Would you accept a patch which reads Retry-After on SERVICE_UNAVAILABLE responses as well?

Sorry for the delay in replying here.

The retry-after header was mostly critical to use back in "v0" of Ads API before we had the async stats endpoint. I think there are cases where it's actually not even returned right now, so if we make this change it should check for case where it's not there and handle it gracefully. It's totally fine to submit pull requests for things like this, this one in particular for many endpoints we may not return it so I would recommend to have some sort of exponential-ish backoff.

We've worked with Twitter developers to resolve the 503 errors we were getting. (it seems it was a capacity issue on their end)
I'll take your word for it that Retry-After is no longer as relevant in the v1/v2 world.
If it comes upon again and we need it I'll open a new issue/PR.

Thanks!