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 Kalnichevski (JIRA)" <ji...@apache.org> on 2017/12/20 08:33:00 UTC
[jira] [Commented] (HTTPCLIENT-1892) Request hangs forever although
sockettimeout and connecttimeout are set
[ https://issues.apache.org/jira/browse/HTTPCLIENT-1892?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16298076#comment-16298076 ]
Oleg Kalnichevski commented on HTTPCLIENT-1892:
-----------------------------------------------
I do not see timeouts configured anywhere in your code. By default HttpClient 4.x uses infinite timeout values (no timeout). No wonder {{SocketInputStream#socketRead0}} blocks indefinitely.
Oleg
> Request hangs forever although sockettimeout and connecttimeout are set
> -----------------------------------------------------------------------
>
> Key: HTTPCLIENT-1892
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1892
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: HttpClient (classic)
> Affects Versions: 4.5.3
> Environment: linux
> Reporter: Christian F
>
> I try to perform a head request with the http client. The client uses a proxy. The requested domain is not existing. But the proxy does not close the connection.
> But what I dont understand, is why the client hangs forever and non of the configured timeouts activates and aborts the request.
> Her is my example code:
> {noformat}
> httpResponse = proxiedHttpClient.execute(
> new HttpHead("https://iAmNotExisting.com/dummy.jpg"))
> {noformat}
> Here is my code for configuring the client:
> {noformat}
> final String hostName = "proxyhost";
> final int port = 1234;
> final HttpClientBuilder clientBuilder = HttpClientBuilder.create();
> clientBuilder.useSystemProperties();
> clientBuilder.setDefaultRequestConfig(RequestConfig.custom().setCookieSpec(STANDARD).build());
> clientBuilder.setProxy(new HttpHost(hostName, port));
> clientBuilder.setDefaultCredentialsProvider(
> getCredentialsProvider(hostName, port, "proxyuser", proxypassword));
> clientBuilder.setProxyAuthenticationStrategy(new ProxyAuthenticationStrategy());
> return clientBuilder.build();
> {noformat}
> Here is a threaddump from the hanging thread:
> {noformat}
> java.lang.Thread.State: RUNNABLE
> at java.net.SocketInputStream.socketRead0(Native Method)
> at java.net.SocketInputStream.socketRead(Unknown Source)
> at java.net.SocketInputStream.read(Unknown Source)
> at java.net.SocketInputStream.read(Unknown Source)
> at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
> at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
> at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:282)
> at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
> at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
> at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
> at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
> at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:165)
> at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
> at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
> at org.apache.http.impl.execchain.MainClientExec.createTunnelToTarget(MainClientExec.java:473)
> at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:398)
> at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
> at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
> at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
> at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
> at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
> at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
> at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
> at de.feed.common.job.HttpClientTestJob.execute(HttpClientTestJob.java:47)
> {noformat}
> Here is the request performed with curl:
> {noformat}
> curl -X HEAD --proxy "proxyuser:proxypassword@proxyhost:1234" "https://iAmNotExisting.com/dummy.jpg" --verbose
> * About to connect() to proxy proxyhost port (#0)
> * Trying 15.112.12.32...
> * Connected to proxyhost (15.112.12.32) port 1234 (#0)
> * Establish HTTP proxy tunnel to iAmNotExisting.com:443
> * Proxy auth using Basic with user 'proxyuser'
> > CONNECT iAmNotExisting.com:443 HTTP/1.1
> > Host: iAmNotExisting.com:443
> > Proxy-Authorization: Basic blablub=
> > User-Agent: curl/7.29.0
> > Proxy-Connection: Keep-Alive
> >
> * Operation timed out after 300314 milliseconds with 0 out of 0 bytes received
> * Closing connection 0
> curl: (28) Operation timed out after 300314 milliseconds with 0 out of 0 bytes received
> {noformat}
> I think, this is either a bug, because the socket timeout does not work or that a request timeout would be needed if the socket timeout is not intended for this use case
> The behavior of the proxy could be caused, because it is a keep-alive session.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org