Does this problem comes in PoolingNHttpClientConnectionManager also or
pooling manager handles this automatically without user being rethrow the
exception from failed callback method of
FutureCallback .
And is it safe to retry the request from failed callback .
some sort of
future = httpclient.execute(request1,new
AsyncHttpCallbackHandler(closeableHttpAsyncClient,request, currentRetry,
maxRetry));
class AsyncHttpCallbackHandler implements FutureCallback<HttpResponse>{
public void failed(Exception ex) {
//retry check and retry the request
closeableHttpAsyncClient.execute(request,this);
}
}
On Tue, Jul 28, 2015 at 6:48 PM, Oleg Kalnichevski <[email protected]> wrote:
> On Tue, 2015-07-28 at 20:45 +0800, Cap zhou wrote:
> > Hi:
> >
> > I want to close the underlying connection if the status code of response
> is
> > not 2XX, or I don't want the connection to be reused if any request on it
> > has ever failed. how? I am using httpasyncclient 4.0.2.
> >
> > why I want to do this? Because in some situations my server may return
> > error right after it finished receiving the http headers while the body
> is
> > not completed. And the client may stop sending body if it receive the
> > response. And if the connection is reused by another request, the data of
> > http header of the new request may consider to be the rest body data of
> the
> > last request. Then the second request will fail with an unexpected
> > exception.
> >
> > My solution to this problem is: don't reuse the connection if any request
> > has failed it.
>
> Use a custom response consume and throw an exception from any of its
> methods. That will lead to termination of the current session and the
> underlying connection.
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>