youngzil created HTTPCLIENT-2243:
------------------------------------

             Summary: DefaultHttpRequestRetryStrategy Retrying the request 
without sending the body causes the connection to time out
                 Key: HTTPCLIENT-2243
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2243
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpClient (async)
    Affects Versions: 5.1.3
            Reporter: youngzil


Apache httpclient 5.1.3 not sending POST data on retry via 
DefaultHttpRequestRetryStrategy
 
I didn't set any retry strategy for CloseableHttpAsyncClient, so use default 
retry strategy DefaultHttpRequestRetryStrategy、

I am making a POST call to the server with JSON payload in SimpleHttpRequest.

I call the execute method like public final Future<SimpleHttpResponse> 
execute(final SimpleHttpRequest request,final 
FutureCallback<SimpleHttpResponse> callback)

When server returns with "429 Too Many Requests" the retry strategy kicks in 
and makes another retry request .

I have enabled the logs and what I observe is, in the first request the JSON 
payload is sent properly. But on the retry request no payload is sent to the 
server and I am receiving a "400 Bad Request".


Through the tracking code, the reasons are found as follows:

Eventually a SimpleRequestProducer.create(request) will be created that 
contains a dataProducer and the dataProducer has the requested body, and 
BasicAsyncEntityProducer.isRepeatable return true

The first request will call 
org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer#produce to launch 
the body

When initiating a retry request, calling 
org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer#produce again the 
body will not be sent again, because bytebuf.hasRemaining() returns false

This looks like a problem

BasicAsyncEntityProducer isRepeatable but the produce method cannot be called 
repeatedly

thanks



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to