[
https://issues.apache.org/jira/browse/HTTPCLIENT-1892?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17542840#comment-17542840
]
preethi commented on HTTPCLIENT-1892:
-------------------------------------
Hi, Getting socket Read exeception even after adding
{{{}setDefaultSocketConfig{}}}.
Code
clientBuilder.setDefaultSocketConfig(SocketConfig.custom()
.setSoTimeout(Configuration.getInteger("zcfunctions.http.function.socket.timeout",5*60*1000))
.build());
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(Configuration.getInteger("faasToFCConnectTimeoutTime", 30 *
1000))
.setSocketTimeout(Configuration.getInteger("faasToFCSocketTimeoutTime", 15 * 60
* 1000 ))
.build();
Stack trace
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
java.net.SocketInputStream.read(SocketInputStream.java:171)
java.net.SocketInputStream.read(SocketInputStream.java:141)
java.net.MIInputStream.read(MIInputStream.java:32)
sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:476)
sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:470)
sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:70)
sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1369)
sun.security.ssl.SSLSocketImpl.access$300(SSLSocketImpl.java:73)
sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:978)
org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157)
org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
> 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
> Priority: Major
>
> 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)
> .setConnectionRequestTimeout((int) Duration.ofSeconds(1).toMillis())
> .setSocketTimeout((int) Duration.ofSeconds(1).toMillis())
> .setConnectTimeout((int) Duration.ofSeconds(1).toMillis()).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
(v8.20.7#820007)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]