Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-2243

DefaultHttpRequestRetryStrategy Retrying the request without sending the body causes the connection to time out

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.1.3
    • None
    • HttpClient (async)
    • None

    Description

      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

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              youngzil youngzil
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: