You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Jaroslav Bielcik <bi...@gmail.com> on 2008/10/27 15:18:41 UTC

ConnectException not handled in DefaultHttpMethodRetryHandler

Hi,

i am using commons-httpclient.3.0.1 and I am sending some requests
through https protocol. I have a problem with a long creation of
connection if ip address of remote service is not existing. I think
problem is in the situation when https connection is not created and
ConnectException is thrown after connection timeout. This exception is
catched in HttpMethodDirector.java in method executeWithRetry. Then
the DefaultHttpMethodRetryHandler is called to recognize whether
connection creation will be repeated or not.
I think, that special handling for ConnectException is missing in
retryMethod of DefaultHttpMethodRetryHandler, because exception is not
recognized and connetions are created again.
On the other hand, ConnectTimeoutException is thrown after connection
timeout for HTTP. This exception is handled in
DefaultHttpMethodRetryHandler and call is stopped.

These lines of code handle ConnectTimeoutException in retryMethod of
DefaultHttpMethodRetryHandler:
if (exception instanceof InterruptedIOException) {
            // Timeout
            return false;
        }

Probably this is missing for ConnectException:
if (exception instanceof InterruptedIOException || exception
instanceof ConnectException) {
            // Timeout
            return false;
        }

Or is this problem handled in next versions? (I tried v3.1 and same problem)

Thanks,
Jaro

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: ConnectException not handled in DefaultHttpMethodRetryHandler

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2008-10-27 at 15:18 +0100, Jaroslav Bielcik wrote:
> Hi,
> 
> i am using commons-httpclient.3.0.1 and I am sending some requests
> through https protocol. I have a problem with a long creation of
> connection if ip address of remote service is not existing. I think
> problem is in the situation when https connection is not created and
> ConnectException is thrown after connection timeout. This exception is
> catched in HttpMethodDirector.java in method executeWithRetry. Then
> the DefaultHttpMethodRetryHandler is called to recognize whether
> connection creation will be repeated or not.
> I think, that special handling for ConnectException is missing in
> retryMethod of DefaultHttpMethodRetryHandler, because exception is not
> recognized and connetions are created again.
> On the other hand, ConnectTimeoutException is thrown after connection
> timeout for HTTP. This exception is handled in
> DefaultHttpMethodRetryHandler and call is stopped.
> 
> These lines of code handle ConnectTimeoutException in retryMethod of
> DefaultHttpMethodRetryHandler:
> if (exception instanceof InterruptedIOException) {
>             // Timeout
>             return false;
>         }
> 
> Probably this is missing for ConnectException:
> if (exception instanceof InterruptedIOException || exception
> instanceof ConnectException) {
>             // Timeout
>             return false;
>         }
> 
> Or is this problem handled in next versions? (I tried v3.1 and same problem)
> 
> Thanks,
> Jaro
> 

Jaroslav,

Feel free to open a bug in JIRA for this problem. It will get fixed in
HttpClient 4.0. To work this problem around for HttpClient 3.x simply
provide a custom implementation of HttpMethodRetryHandler

Hope this helps

Oleg


> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org