hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg Kalnichevski (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1425) Socket Closed Exception When Reading Connection: close Response Entities
Date Sat, 19 Oct 2013 09:26:42 GMT

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

Oleg Kalnichevski commented on HTTPCLIENT-1425:
-----------------------------------------------

{noformat}
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] CachingExec - Cache miss
[DEBUG] PoolingHttpClientConnectionManager - Connection request: [route: {}->http://3roundstones.com:80][total
kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
[DEBUG] PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {}->http://3roundstones.com:80][total
kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
[DEBUG] MainClientExec - Opening connection {}->http://3roundstones.com:80
[DEBUG] HttpClientConnectionManager - Connecting to 3roundstones.com/198.61.176.176:80
[DEBUG] MainClientExec - Executing request GET / HTTP/1.1
[DEBUG] MainClientExec - Target auth state: UNCHALLENGED
[DEBUG] MainClientExec - Proxy auth state: UNCHALLENGED
[DEBUG] headers - http-outgoing-0 >> GET / HTTP/1.1
[DEBUG] headers - http-outgoing-0 >> Host: 3roundstones.com
[DEBUG] headers - http-outgoing-0 >> Connection: Keep-Alive
[DEBUG] headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.3.1 (java 1.5)
[DEBUG] headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate
[DEBUG] headers - http-outgoing-0 >> Via: 1.1 localhost (Apache-HttpClient/4.3.1 (cache))
[DEBUG] headers - http-outgoing-0 << HTTP/1.1 200 OK
[DEBUG] headers - http-outgoing-0 << Date: Sat, 19 Oct 2013 09:27:07 GMT
[DEBUG] headers - http-outgoing-0 << Server: Apache/2.2.15 (CentOS)
[DEBUG] headers - http-outgoing-0 << X-Powered-By: PHP/5.3.3
[DEBUG] headers - http-outgoing-0 << X-Pingback: http://3roundstones.com/xmlrpc.php
[DEBUG] headers - http-outgoing-0 << Connection: close
[DEBUG] headers - http-outgoing-0 << Transfer-Encoding: chunked
[DEBUG] headers - http-outgoing-0 << Content-Type: text/html; charset=UTF-8
[DEBUG] DefaultManagedHttpClientConnection - http-outgoing-0: Shutdown connection
[DEBUG] MainClientExec - Connection discarded
[DEBUG] DefaultManagedHttpClientConnection - http-outgoing-0: Close connection
[DEBUG] PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {}->http://3roundstones.com:80][total
kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
[DEBUG] PoolingHttpClientConnectionManager - Connection manager is shutting down
[DEBUG] PoolingHttpClientConnectionManager - Connection manager shut down
{noformat}

Works for me. There must be something else.

Oleg

> Socket Closed Exception When Reading Connection: close Response Entities
> ------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1425
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1425
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpCache
>    Affects Versions: 4.3.1
>         Environment: java version "1.7.0_25"
> OpenJDK Runtime Environment (IcedTea 2.3.12) (7u25-2.3.12-4ubuntu3)
> OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
>            Reporter: James Leigh
>             Fix For: 4.3.2
>
>
> If the server closes the TCP connection, immediately after sending the complete response,
httpclient-cache will throw socket closed exception.
> The server at http://3roundstones.com/ will close the response immediately after sending
the complete response and will include the headers: Connection: close and Transfer-Encoding:
chunked.
> HttpClient can deal with this response no problem (using HttpClients.createDefault).
However, CachingHttpClients.createMemoryBound throws an exception every time I try it. Below
is some code (mostly taken of the docs) that also fails every time. Further down is the stack
trace it produces.
> CacheConfig cacheConfig = CacheConfig.custom().build();
> RequestConfig requestConfig = RequestConfig.custom().build();
> CloseableHttpClient httpclient = CachingHttpClients.custom()
> 		.setCacheConfig(cacheConfig)
> 		.setDefaultRequestConfig(requestConfig).build();
> HttpCacheContext context = HttpCacheContext.create();
> HttpGet httpget = new HttpGet("http://3roundstones.com/");
> CloseableHttpResponse response = httpclient.execute(httpget, context);
> try {
> 	String body = EntityUtils.toString(response.getEntity());
> 	assertTrue(body.length() > 0);
> } finally {
> 	response.close();
> 	httpclient.close();
> }
> java.net.SocketException: Socket closed
> 	at java.net.SocketInputStream.socketRead0(Native Method)
> 	at java.net.SocketInputStream.read(SocketInputStream.java:150)
> 	at java.net.SocketInputStream.read(SocketInputStream.java:121)
> 	at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:136)
> 	at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:152)
> 	at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:270)
> 	at org.apache.http.impl.io.ChunkedInputStream.getChunkSize(ChunkedInputStream.java:240)
> 	at org.apache.http.impl.io.ChunkedInputStream.nextChunk(ChunkedInputStream.java:206)
> 	at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:169)
> 	at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:137)
> 	at java.io.SequenceInputStream.read(SequenceInputStream.java:208)
> 	at java.io.SequenceInputStream.read(SequenceInputStream.java:211)
> 	at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
> 	at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
> 	at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
> 	at java.io.InputStreamReader.read(InputStreamReader.java:184)
> 	at java.io.Reader.read(Reader.java:140)
> 	at org.apache.http.util.EntityUtils.toString(EntityUtils.java:244)
> 	at org.apache.http.util.EntityUtils.toString(EntityUtils.java:288)



--
This message was sent by Atlassian JIRA
(v6.1#6144)

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


Mime
View raw message