1
votes

In apache httpclient 4.3, DefaultHttpRequestRetryHandler's code

    if (exception instanceof InterruptedIOException) {
        // Timeout
        return false;
    }

It won't retry if it's timeout. What's the reason? Sometimes, the network is not stable, I just want to retry connection. I can use my own RetryHandler, but I just want to make sure if there is any problem if I retry when timeout.

2
Why aren't you using catch (InterruptedIOException ...)? - user207421
@Xilang I also want to retry in this case. Did you try overwriting the RetryHander to retry on InterruptedIOException? If so, how did it go? - Tadhg

2 Answers

0
votes

It won't retry if it's timeout. What's the reason?

Why should it? Timeouts usually defines a maximum period of inactivity between two consecutive operations. Why should the request be retried if it times out in the first place? If you are willing to wait longer for the operation to complete you should be using a greater timeout value.

0
votes

This helped me. I tried to disable the retry option. The code below does the opposite.

DefaultHttpClient httpClient = new DefaultHttpClient();
DefaultHttpRequestRetryHandler retryHandler = new DefaultHttpRequestRetryHandler(0, true);
httpClient.setHttpRequestRetryHandler(retryHandler);

Thanks