hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From SomuReddy <chowdareddy.s...@gmail.com>
Subject Re: [jira] Commented: (HTTPCLIENT-1012) ThreadSafeClientConnManager Connection pool leak issue
Date Thu, 14 Oct 2010 14:39:33 GMT


Thanks Oleg, hope I'm replying now from right place.,

Few things, we are using the F5 load balancer between back end servers and
our application. So our application is going to send http request to load
balancer not directly to back end server.

So do we need to take any special care when we are using the HttpClient to
send http request to Load Balancer in terms of connection pool?

FYI.. Some times we won't get the response from back end servers due to some
data problems so we see lot of 500 status exceptions from servers. when we
got bunch of these exceptions.. we are seeing the 'Timeout waiting for
connection' because there is no free connection left in pool. though we are
doing abort() and consumeContent() when we got any exception..  

but we never use closeExpiryConnections(), is it worth to call this method
when we got exception?

can you suggest any other things we need to take care when we are using  the
Http4.0.3 Cooonectionpool (ThreadSafeClientConnManager)  to work efficiency
manner?

Thanks..





JIRA jira@apache.org wrote:
> 
> 
>     [
> https://issues.apache.org/jira/browse/HTTPCLIENT-1012?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12920738#action_12920738
> ] 
> 
> Oleg Kalnichevski commented on HTTPCLIENT-1012:
> -----------------------------------------------
> 
>> My question is there if any socket connection exception happens while
>> executing the Http Request then the response object
>>  is null so there is nothing to consume the content, what happens in this
>> case.. 
> 
> connection will be shut down and automaticaly released back to the pool
> 
>> will that connection is going back to the pool?
> 
> Yes, it will
> 
>> If I close the expiry connection using the closeExpiredConnections()
>> method , will it create new connection for that?? 
> 
> Those connections will be evicted from the pool and new connections will
> be created when needed
> 
>> I don't understand why it says, connection Closed, connection shut down
>> and released connection is not reusable?
> 
> The log is somewhat noisy. Basically if a connection throws an exception
> (including socket timeout) in the course of HTTP request execution
> HttpClient shuts down that connection as it may be left in a inconsistent
> state and therefore considered non-reusable.
> 
> _Please_ post your questions to the HttpClient user list. Jira is not a
> support forum.
> 
> 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
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/-jira--Created%3A-%28HTTPCORE-238%29-ThreadSafeClientConnManager-Connection-pool--leak-issue-tp29947072p29962982.html
Sent from the HttpComponents-Dev mailing list archive at Nabble.com.


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


Mime
View raw message