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 Aaron Shettleroe <aa...@touchnet.com> on 2008/04/02 17:32:15 UTC

Duplicate requests

It appears that HttpClient is sending the same request more than once.
I tried to code against this.

Here is some code snippets:

private static HttpClient httpClient;
...

final HttpConnectionManagerParams params =
            new HttpConnectionManagerParams();
// set some params: timeouts, max conns
...

final MultiThreadedHttpConnectionManager connectionManager = 
   new MultiThreadedHttpConnectionManager();
connectionManager.setParams(params);
httpClient = new HttpClient(connectionManager);

...

// I define a RetryHandler
getMethod.getParams().setParameter(
   HttpMethodParams.RETRY_HANDLER,
   updateRetryHandler);

...

// My retry logic.  Only retry if a connection exception:
// Don't retry if the maximum retry count has been reached
if(executionCount >= MAX_RETRY_COUNT)
{
   return false;
}
else if(!method.isRequestSent()
          && (exception instanceof ConnectException
              || exception instanceof ConnectTimeoutException))
{
   return true;
}

return false;

However, the request is being sent more than once.

Would the stale checking be the cause of this?  Does the stale checking
actually send the request?

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


Re: Duplicate requests

Posted by Oleg Kalnichevski <ol...@apache.org>.
Aaron Shettleroe wrote:
> It appears that HttpClient is sending the same request more than once.

Unlikely, unless the RetryHandler is configured to do so.


> I tried to code against this.
> 
> Here is some code snippets:
> 
> private static HttpClient httpClient;
> ...
> 
> final HttpConnectionManagerParams params =
>             new HttpConnectionManagerParams();
> // set some params: timeouts, max conns
> ...
> 
> final MultiThreadedHttpConnectionManager connectionManager = 
>    new MultiThreadedHttpConnectionManager();
> connectionManager.setParams(params);
> httpClient = new HttpClient(connectionManager);
> 
> ...
> 
> // I define a RetryHandler
> getMethod.getParams().setParameter(
>    HttpMethodParams.RETRY_HANDLER,
>    updateRetryHandler);
> 
> ...
> 
> // My retry logic.  Only retry if a connection exception:
> // Don't retry if the maximum retry count has been reached
> if(executionCount >= MAX_RETRY_COUNT)
> {
>    return false;
> }
> else if(!method.isRequestSent()
>           && (exception instanceof ConnectException
>               || exception instanceof ConnectTimeoutException))
> {
>    return true;
> }
> 
> return false;
> 
> However, the request is being sent more than once.
> 

Please post a context/wire log of the session.

http://hc.apache.org/httpclient-3.x/logging.html


> Would the stale checking be the cause of this?  Does the stale checking
> actually send the request?
> 

No, it does not

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