[prev in list] [next in list] [prev in thread] [next in thread]
List: httpclient-users
Subject: Calling closeIdleConnections ThreadSafeClientConnManager not working
From: "Mugoma Joseph Okomba" <mugoma () yengas ! com>
Date: 2012-05-21 18:15:20
Message-ID: 76908922364dd925394aa98e3c054ea3.squirrel () simba ! yenhost ! com
[Download RAW message or body]
Hello,
I am calling closeIdleConnections () on ThreadSafeClientConnManager object
every time a method is executed.
However I am ending up with a lot of connections in CLOSE_WAIT state for
long time. What can I do to ensure that these are closed?
Thanks.
Mugoma Joseph.
------------------
SAMPLE CODE:
private static ThreadSafeClientConnManager connectionManager = null;
private static final long MAX_CONNECTION_IDLE_TIME = 60000; // milliseconds
static {
connectionManager = new ThreadSafeClientConnManager();
connectionManager.setDefaultMaxPerRoute(1000);
connectionManager.setMaxTotal(1000);
httpClient = new DefaultHttpClient(connectionManager);
}
Then:
/*
* Check URL
*/
public void getObject(String url) throws Exception {
try {
}
catch (java.io.InvalidClassException except) {
}
catch (IOException except) {
except.printStackTrace();
throw except;
}
finally {
//IOUtils.closeQuietly(oin);
//getMethod.releaseConnection();
//connectionManager.closeIdleConnections(MAX_CONNECTION_IDLE_TIME);
connectionManager.closeIdleConnections(MAX_CONNECTION_IDLE_TIME,
TimeUnit.MILLISECONDS);
connectionManager.closeExpiredConnections();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic