HttpClient
executes request 4 times if it times out. If it does not time out then it is working fine. Is it related to HttpClient
?
I found that it is HttpClient
's default behaviour to execute requests 4 times if it fails. I am not sure about other kind of failures but at least with time out.
To disable this behaviour do this :
DefaultHttpClient client = new DefaultHttpClient();
// Disable default behavior of HttpClient of retrying requests in case of failure
((AbstractHttpClient) client).setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
Here retry count is set to 0
to disable retry.
I found solution from this blog.
This resolved the issue for me. Using httpclient 4.3 and above.
HttpClientBuilder.create().disableAutomaticRetries().build();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With