hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mugoma Joseph Okomba" <mug...@yengas.com>
Subject Calling closeIdleConnections ThreadSafeClientConnManager not working
Date Mon, 21 May 2012 18:15:20 GMT
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


Mime
View raw message