Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

No Retry-After header is found in 429 response


#1

Hello,

I was running parallel tests and uploading the test result to test rail after each test. We had
HTTP status code 429 with too many request message in some occasions. With the suggestion from other posts in this discussion forum, I tried to retrieve the number of seconds from the Retry-After header in the response but no Retry-After headers exists in the response header. I am now handling this case with hard coded 5 seconds wait time in case such exception occurs but it would be nice if we don’t have to hard code it. below is a block of code from sendRequest Java method that you provided. I did some modifications to return an integer as waiting time in case 429 exception occurs. I also logged the the full header to see if Retry-After header is present or not ( it is not). Could you please check if there is anything wrong with my code or that header is not valid in your side anymore?

if (status != 200) {
String error = “No additional error message received”;
if (result != null && result instanceof JSONObject) {
JSONObject obj = (JSONObject) result;
if (obj.containsKey(“error”)) {
error = ‘"’ + (String) obj.get(“error”) + ‘"’;
}
throw new RailAPIException("TestRail API returned HTTP " + status + “(” + error + “)”);
} else if (status == 429) {
logger.info("header: " + conn.getHeaderFields());
result = conn.getHeaderFieldInt(“Retry-After”, 5);
logger.info("retry after: " + result.toString());
} else {
throw new RailAPIException("TestRail API returned HTTP " + status + “(” + error + “)”);
}
}

	return result;