hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Heisey <apa...@elyograg.org>
Subject Re: Getting SocketTimeoutException after a very short amount of time
Date Fri, 04 Sep 2015 17:39:48 GMT
On 9/4/2015 7:53 AM, Oleg Kalnichevski wrote:
> I added socket timeout logging to the 4.5.x branch and trunk
>
> http://svn.apache.org/r1701258
>
> I clearly those values logged when executing HttpClient examples. 

I abandoned my custom httpcore jar built from the 4.4.1 tag with the one
line addition, pulled down the 4.5.x branch of httpclient, and built
it.  I replaced httpclient-4.5.jar with httpclient-4.5.1-SNAPSHOT.jar,
and verified that the commit you made was included in the source code
that I checked out.

Because I am using slf4j which ultimately logs to log4j1, I do have the
jcl-over-slf4j jar in my classpath, which should capture the commons
logging that httpclient uses.  I put the following in my
log4j.properties file:

log4j.logger.org.apache.http=DEBUG, file

During program startup (when I build the HttpClient objects), I do not
see any logs from httpclient at all, but when it actually connects to
Solr, I do see DEBUG logs.  Those debug logs do not include the "set
socket timeout" log entry that you added.  One of the logs says this:

DEBUG - 2015-09-04 11:38:01.551;   262; 3; Connection [id: 1][route:
{}->http://bigindy5.REDACTED.com:8982] can be kept alive indefinitely

I must be creating the client objects incorrectlyfor the "set socket
timeout" message to never be logged.  So you don't have to go looking
back through the thread, here is the code I'm using:

    /* Trying out a new way of creating clients */
    RequestConfig requestConfig = RequestConfig.custom()
      .setSocketTimeout(900000)
      .setConnectTimeout(15000)
      .build();
    httpClient = HttpClients.custom()
      .setDefaultRequestConfig(requestConfig)
      .setMaxConnPerRoute(300)
      .setMaxConnTotal(5000)
      .build();
    RequestConfig optimizeRequestConfig = RequestConfig.custom()
      .setSocketTimeout(7200000)
      .setConnectTimeout(15000)
      .build();
    optimizeHttpClient = HttpClients.custom()
      .setDefaultRequestConfig(optimizeRequestConfig)
      .build();

Thanks,
Shawn


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


Mime
View raw message