hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Retry on ConnectionException
Date Mon, 21 Feb 2005 15:13:26 GMT
On Mon, Feb 21, 2005 at 05:02:40PM +0300, Riad Souissi wrote:
> 
> But if the open() throws ConnectionException (as is my case), since the
> try/catch wrapping the open() is not inside the while() but on top of
> it, it stops the loop and the retry handler does not get a chance to be
> invoked (I believe this is what happens, my retry handler is never
> invoked in this case, and I applied it on the client as well as on the
> post method).

Confirmed. Please file a bug report. Thanks for tracking it down.

Oleg



> 
> Again, I may be missig something here... :)
> 
> riad
> 
> -----Original Message-----
> From: Oleg Kalnichevski [mailto:olegk@apache.org]
> Sent: Monday, February 21, 2005 4:19 PM
> To: HttpClient User Discussion
> Subject: Re: Retry on ConnectionException
> 
> On Mon, Feb 21, 2005 at 04:08:58PM +0300, Riad Souissi wrote:
> >
> >
> > I had my own RetryHandler, however, the Connection Timeout exception
> > never falls in it.
> > I took a look at the source code and noticed that the open() method
> > and any thrown exception at this level occurs outside the control of
> > the Retry Handler (which seems to be involved only after open()
> succeeds).
> >
> > Is that correct or am I missing something ?
> 
> Riad,
> See for yourself:
> 
> http://jakarta.apache.org/commons/httpclient/3.0/xref/org/apache/commons
> /httpclient/HttpMethodDirector.html#359
> 
> Connections ARE open within the retry loop. The problem is that one must
> set a retry handler either on host or client level for it to have an
> effect on CONNECT methods
> 
> Hope this explains it
> 
> Oleg
> 
> 
> >
> > Thanks
> > riad
> >
> > -----Original Message-----
> > From: Oleg Kalnichevski [mailto:olegk@apache.org]
> > Sent: Wednesday, February 16, 2005 11:50 PM
> > To: HttpClient User Discussion
> > Subject: Re: Retry on ConnectionException
> >
> > Riad,
> >
> > Per default HttpClient does not automatically retry requests upon
> > connection timeout. However, nothing prevents you from providing a
> > custom retry handler to override this behavior:
> >
> > public class DefaultHttpMethodRetryHandler
> >   implements HttpMethodRetryHandler {
> >
> > ...
> >     public boolean retryMethod(
> >         final HttpMethod method,
> >         final IOException exception,
> >         int executionCount) {
> >
> > ...
> >         if (executionCount > this.retryCount) {
> >             // Do not retry if over max retry count
> >             return false;
> >         }
> >         if (exception instanceof NoHttpResponseException) {
> >             // Retry if the server dropped connection on us
> >             return true;
> >         }
> >         if (exception instanceof InterruptedIOException) {
> >             // Timeout
> >             return false; // return true instead
> >         }
> > ...
> >         // otherwise do not retry
> >         return false;
> >     }
> >
> > See <http://jakarta.apache.org/commons/httpclient/3.0/exception-
> > handling.html#Custom%20exception%20handler> for details
> >
> > Cheers,
> >
> > Oleg
> >
> >
> > On Mon, 2005-02-14 at 16:21 +0300, Riad Souissi wrote:
> > > Hi,
> > >
> > > I noticed that the Retry handler mechanism does not work when the
> > > client cannot initiate a connection (which throws
> > > java.net.ConnectionException).
> > > This happens for me for instance when there is proxy and a tunneling
> 
> > > in the picture and sometimes there are connectivity problems.
> > > Of course, it is possible to build the retry on top of the
> > > HTTPClient,
> >
> > > but it would be nice to use the same RetryHandler framework for
> that.
> > >
> > > I believe a ConnectionException is a typical transiant error that
> > > can be retried safely for those who want to enable it.
> > > Any opinion ?
> > >
> > > thanks
> > > riad
> > >
> > >
> > > DiscalimerThe information in this email and in any files transmitted
> 
> > > with it, is intended only for the addressee and may contain
> > confidential and/or privileged material.
> > > Access to this email by anyone else is unauthorized. If you receive
> > > this in error, please contact the sender immediately and delete the
> > material from any computer.
> > > If you are not the intended recipient, any disclosure, copying,
> > > distribution or any action taken or omitted to be taken in reliance
> > > on
> > it, is strictly prohibited.
> > > Statement and opinions expressed in this e-mail are those of the
> > > sender, and do not necessarily reflect those of STC.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > httpclient-user-help@jakarta.apache.org
> >
> >
> > DiscalimerThe information in this email and in any files transmitted
> > with it, is intended only for the addressee and may contain
> confidential and/or privileged material.
> > Access to this email by anyone else is unauthorized. If you receive
> > this in error, please contact the sender immediately and delete the
> material from any computer.
> > If you are not the intended recipient, any disclosure, copying,
> > distribution or any action taken or omitted to be taken in reliance on
> it, is strictly prohibited.
> > Statement and opinions expressed in this e-mail are those of the
> > sender, and do not necessarily reflect those of STC.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > httpclient-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 
> 
> DiscalimerThe information in this email and in any files transmitted with it,
> is intended only for the addressee and may contain confidential and/or privileged material.
> Access to this email by anyone else is unauthorized. If you receive this in error,
> please contact the sender immediately and delete the material from any computer.
> If you are not the intended recipient, any disclosure, copying, distribution or
> any action taken or omitted to be taken in reliance on it, is strictly prohibited.
> Statement and opinions expressed in this e-mail are those of the sender, and do not
> necessarily reflect those of STC.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 

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


Mime
View raw message