You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Oleg Golovanov (JIRA)" <ji...@apache.org> on 2015/07/31 16:45:04 UTC

[jira] [Commented] (HTTPCLIENT-1660) Http client 4.3.6 - loooong timeout on socket close

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14649297#comment-14649297 ] 

Oleg Golovanov commented on HTTPCLIENT-1660:
--------------------------------------------

Sorry, it was my problem.
The correct way to abort connection - use request.abort(), that sends RESET packet.
I did it wrong way - just stopped reading input stream and closed stream with instream.close()

> Http client 4.3.6 - loooong timeout on socket close
> ---------------------------------------------------
>
>                 Key: HTTPCLIENT-1660
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1660
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.3.6
>         Environment: ogolovanov@ostrovok:~$ uname -a
> Linux ostrovok 3.2.0-74-generic #109-Ubuntu SMP Tue Dec 9 16:45:49 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
> ogolovanov@ostrovok:~$ lsb_release -a
> No LSB modules are available.
> Distributor ID:	Ubuntu
> Description:	Ubuntu 12.04.5 LTS
> Release:	12.04
> Codename:	precise
>            Reporter: Oleg Golovanov
>
> I am not sure, is this bug related to http client or linux system or something else.
> I have http client with pooling connection manager.
> Requests done to http service using different proxies.
> Configuration:
> {quote}
>         PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry);
>         cm.setMaxTotal(3000);
>         cm.setDefaultMaxPerRoute(3000);
>         cm.setDefaultSocketConfig(SocketConfig.custom().setSoTimeout(20000).build());
> {quote}
> {quote}
> RequestConfig.custom()
>                 .setConnectionRequestTimeout(0)
>                 .setSocketTimeout(20000)
>                 .setConnectTimeout(3000)
>                 .setRedirectsEnabled(true)
>                 .setMaxRedirects(10)
>                 .setStaleConnectionCheckEnabled(false)
>                 .build();
> {quote}
> {quote}
> HttpClients.custom()
>                 .setConnectionManager(connectionManager)
>                 .setRetryHandler(new DefaultHttpRequestRetryHandler())
>                 .setDefaultRequestConfig(requestConfig)
>                 .setDefaultHeaders(headers)
>                 .setUserAgent(userAgent)
>                 .setRedirectStrategy(new LaxRedirectStrategy())
>                 .setSSLSocketFactory(sslCsf)
>                 .setHostnameVerifier(new AllowAllHostnameVerifier())
>                 .build();
> {quote}
> Problem:
> after fetching all bytes from response input stream and closing it, thread can stuck for an hour or even more.
> {quote}
> 2015-06-19 14:31:32,645 pool-5-thread-357       TRACE   lib.Toolkit     Closing stream
> 2015-06-19 15:34:20,102 pool-5-thread-357       DEBUG   org.apache.http.impl.conn.DefaultManagedHttpClientConnection    http-outgoing-680033: Shutdown connection
> 2015-06-19 15:34:20,102 pool-5-thread-357       DEBUG   org.apache.http.impl.execchain.MainClientExec   Connection discarded
> 2015-06-19 15:34:20,102 pool-5-thread-357       DEBUG   org.apache.http.impl.conn.DefaultManagedHttpClientConnection    http-outgoing-680033: Close connection
> 2015-06-19 15:34:20,102 pool-5-thread-357       DEBUG   org.apache.http.impl.conn.PoolingHttpClientConnectionManager    Connection released: [id: 680033][route: {}->http://46.28.69.176:40751->http://yan
> dex.ru:80][total kept alive: 0; route allocated: 0 of 3000; total allocated: 0 of 3000]
> 2015-06-19 15:34:20,103 pool-5-thread-357       DEBUG   lib.job.search_engine.SearchEngineJob   Error, class="SocketTimeoutException", message="Read timed out"
> {quote}
> So, its took more than an hour just to close connection ( read timed out occurred ), even though socket timeout set to 20 seconds.
> How to solve this problem?
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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