Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Not the solution, but more of an explanation of what is going on.</p> <p>What you are doing is correct. </p> <p>First of all, if you are using Log4J, make sure you see everything that HttpClient wants to show you:</p> <pre><code>log4j.logger.org.apache.http=trace </code></pre> <p>Then take a look at this class:</p> <p><a href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/DefaultClientConnectionOperator.html">http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/DefaultClientConnectionOperator.html</a></p> <blockquote> <p>This connection operator is multihome network aware and <strong>will attempt to retry failed connects against all known IP addresses sequentially until the connect is successful or all known addresses fail to respond.</strong> Please note the same CoreConnectionPNames.CONNECTION_TIMEOUT value will be used for each connection attempt, so in the worst case the total elapsed time before timeout can be <strong>CONNECTION_TIMEOUT * n</strong> where n is the number of IP addresses of the given host.</p> </blockquote> <p>That's what most likely is happening in your case.</p> <p>Also, it is better to use constants from this interface <strong><a href="http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/params/CoreConnectionPNames.html">HttpConnectionParams</a></strong>:</p> <pre><code>SO_TIMEOUT = "http.socket.timeout" TCP_NODELAY = "http.tcp.nodelay" SOCKET_BUFFER_SIZE = "http.socket.buffer-size" SO_LINGER = "http.socket.linger" SO_REUSEADDR = "http.socket.reuseaddr" CONNECTION_TIMEOUT = "http.connection.timeout" STALE_CONNECTION_CHECK = "http.connection.stalecheck" MAX_LINE_LENGTH = "http.connection.max-line-length" MAX_HEADER_COUNT = "http.connection.max-header-count" MIN_CHUNK_LIMIT = "http.connection.min-chunk-limit" </code></pre> <p>You need only two of them:</p> <pre><code>HttpConnectionParams.CONNECTION_TIMEOUT HttpConnectionParams.SO_TIMEOUT </code></pre> <p>So the best way to solve this is to implement a custom <strong>ClientConnectionOperator.resolveHostname</strong> method that returns only one IP address.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload