jira-importer opened a new issue, #1353: URL: https://github.com/apache/httpcomponents-core/issues/1353
**[Simona Afifi](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=simona_afifi)** opened **[HTTPCORE-237](https://issues.apache.org/jira/browse/HTTPCORE-237?redirect=false)** and commented We are using ThreadSafeClientConnManager and we close the stream at the finally block and yet we see very frequent occurences of this exception: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:130) at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:127) at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:233) at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:98) at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:210) at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:271) at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:227) at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:209) at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:292) at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:126) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:483) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554) Sample code: HttpClientWrapper.class public HttpResponse execute(HttpPost httpPost, int timeout) throws IOException { HttpClient httpClient = new DefaultHttpClient(connManager, initParams(timeout)); httpClient.getConnectionManager().closeExpiredConnections(); return httpClient.execute(httpPost); } Service.class --- private String invokeHttpGet(HttpGet httpGet) throws Exception { String responseStr=""; HttpEntity entity= null; try{ HttpResponse response = httpClientWrapper.execute(httpGet); entity = response.getEntity(); if (entity != null) { responseStr = EntityUtils.toString(entity); } }catch(Exception e){ if(httpGet!=null) httpGet.abort(); throw e; }finally{ if(entity!=null) entity.consumeContent(); } return responseStr; } --- **Affects:** 4.0.1 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
