i am experiencing some weird behaviour which i cannot explain. For my use case i use awaitility and httpRequests to check whether a service is already deployed or not. OpenShift returns 503 if the service is not ready yet, 200 otherwise. After 2 requests (which receive 503) the normal behavior turns into timeouts. Manual request still receive 503 and 200 after around 2 minutes.
22-05-2020 11:56:33.448 INFO RetryingHttpClient.send[32] - Sending request: GET https://serviceurl HTTP/1.1
22-05-2020 11:56:33.646 INFO RetryingHttpClient.send[34] - Receiving 503
22-05-2020 11:56:43.987 INFO RetryingHttpClient.send[32] - Sending request: GET https://serviceurl HTTP/1.1
22-05-2020 11:56:43.992 INFO RetryingHttpClient.send[34] - Receiving 503
22-05-2020 11:56:54.071 INFO RetryingHttpClient.send[32] - Sending request: GET https://serviceurl HTTP/1.1
--> TIMEOUT
public void send(HttpUriRequest request) {
log.info("Sending request (retry for 10m): {}", request);
await().atMost(10, TimeUnit.MINUTES)
.pollInterval(5, TimeUnit.SECONDS)
.ignoreExceptions()
.until(() -> client.execute(request), ResponseChecker::is2xxOrRedirectResponse);
}
In order to eliminate some potential causes I have rewritten the logic with a simple for loop, sleep and extended logging and used a some external url which is accessible from everywhere.
public void send(HttpUriRequest request) {
for(int i=1;60>=i;i++){
try {
log.info("Sending request: {}", request);
HttpResponse res = client.execute(request);
log.info("Receiving {}", res.getStatusLine().getStatusCode());
try{
Thread.sleep(10000);
}catch(InterruptedException edf){
System.out.println("Thread was interrupted!");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
22-05-2020 14:56:33.448 INFO RetryingHttpClient.send[32] - Sending request: GET https://www.google.de HTTP/1.1
22-05-2020 14:56:33.686 INFO RetryingHttpClient.send[34] - Receiving 200
22-05-2020 14:56:43.687 INFO RetryingHttpClient.send[32] - Sending request: GET https://www.google.de HTTP/1.1
22-05-2020 14:56:43.770 INFO RetryingHttpClient.send[34] - Receiving 200
22-05-2020 14:56:53.771 INFO RetryingHttpClient.send[32] - Sending request: GET https://www.google.de HTTP/1.1
--> TIMEOUT
If you have any ideas, what the potential causes could be i would be more than happy. Thanks.
Your code is leaking connections. Close responses.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.