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 2010/10/13 00:02:33 UTC

[jira] Resolved: (HTTPCLIENT-1012) ThreadSafeClientConnManager Connection pool leak issue

     [ https://issues.apache.org/jira/browse/HTTPCLIENT-1012?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCLIENT-1012.
-------------------------------------------

       Resolution: Invalid
    Fix Version/s:     (was: 4.0.1)

I do not think there is anything wrong with HttpClient, as I see absolutely no evidence of the resource leak in the library code. Most likely the application code fails to release connections back to the pool. 

http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fundamentals.html#d4e143

You can monitor connection allocation / deallocation by activating the context logging in the connection management code as described here:

http://hc.apache.org/httpcomponents-client-ga/logging.html

Oleg

> ThreadSafeClientConnManager Connection pool  leak issue
> -------------------------------------------------------
>
>                 Key: HTTPCLIENT-1012
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1012
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpConn
>    Affects Versions: 4.0.3
>            Reporter: chowdareddy somu
>
> Hi,
> We are using the HttpClient4.0.3(latest) version for our application where we need to serve the http request to our web app by calling the underlying services.
> Application gets an average 50 threads at a time and we are maintaining the connection pool  on per host basis. we configured the following HttpParam values.. And we are calling the abort() and consumeContent() methods if there are any exceptions due to backed service problem, and for success requests we are extracting the response using the get content method( InputStream is = httpResponse.getEntity().getContent())
> Application runs contionusly for 3 to 4 hrs fine, after that its getting the out of connections and it throws below exception..
> Config Values
> http.connection.timeout = 5000
> http.socket.timeout = 300000
> http.conn-manager.timeout = 1000
> http.conn-manager.max-per-route = 100
> http.conn-manager.max-total = 100
> private static HttpConnectionManagerFactory instance = null;
> 	private Map<String, ClientConnectionManager> map = new HashMap<String, ClientConnectionManager>();
> 	private HttpConnectionManagerFactory() {
> 	}
> 	public static synchronized HttpConnectionManagerFactory getInstance() {
> 		if (instance == null) {
> 			instance = new HttpConnectionManagerFactory();
> 		}
> 		return instance;
> 	}
> 	public synchronized ClientConnectionManager getConnectionManager(URI uri) {
> 		if (!map.containsKey(uri.getHost())) {
> 			HttpParams params = HttpProperties.getInstance().getHttpParams(uri);
> 			SchemeRegistry registry = new SchemeRegistry();
> 			Scheme http = new Scheme("http", PlainSocketFactory.getSocketFactory(), 80);
> 			registry.register(http);
> 			map.put(uri.getHost(), new ThreadSafeClientConnManager(params, registry));
> 		}
> 		return map.get(uri.getHost());
> 	}
> public HttpClient getClient(HttpUriRequest request) {
> 		ClientConnectionManager connectionManager = HttpConnectionManagerFactory.getInstance().getConnectionManager(request.getURI());
> 		HttpParams params = HttpProperties.getInstance().getHttpParams(request.getURI());
>           .............
> }
> HttpClient httpClient = HttpClientFactory.getInstance().getClient(httpRequest);
> 			tracker.startTimer();
> 			HttpResponse httpResponse = null;
> 			try {
> 				try {
> 					httpResponse = httpClient.execute(httpRequest);
> 				} finally {
> 					tracker.stopTimer();
> 				}
> 				StatusLine statusLine = httpResponse.getStatusLine();
> 				tracker.setStatusLine(statusLine);
>                         ..........................
>          }
> Caused by: java.io.IOException: org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection
>         at com.proquest.services.ems.service.HttpRetrieve.getFollowingRedirection(HttpRetrieve.java:194)
>         at com.proquest.services.ems.service.MorningstarMediaService.resolveResource(MorningstarMediaService.java:73)
>         ... 46 more
> Caused by: org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection
>         at org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getEntryBlocking(ConnPoolByRoute.java:345)
>         at org.apache.http.impl.conn.tsccm.ConnPoolByRoute$1.getPoolEntry(ConnPoolByRoute.java:228)
>         at org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager$1.getConnection(ThreadSafeClientConnManager.java:172)
>         at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:390)
>         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)
>         at com.proquest.services.ems.service.HttpRetrieve.getFollowingRedirection(HttpRetrieve.java:155)
> any idea???

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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