hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bindul Bhowmik" <bindulbhow...@gmail.com>
Subject Re: Running out of file handles
Date Thu, 15 Feb 2007 19:51:48 GMT

On 2/15/07, Lowell Kirsh <lowellk@gmail.com> wrote:
> Ok, I've read some of the archives and see that other people are
> having the same problem as I am, where they end up with a ton of
> sockets in the CLOSE_WAIT state. What I would like to learn is not how
> to solve that problem in general, but how to solve it in my specific
> case.
> What I'm trying to do is create a WebServiceCall class. The way I've
> done it so far, which is not working out, is for each instance to
> represent a single call to a web service, and not be reusable. Each
> instance has its own HttpClient instance, which I know is wasteful,
> but I am not concerned with being overly efficient in this case.
> So how it works is like this: create a WebServiceCall, which creates a
> new HttpClient object. Then call WebServiceCall.execute() which calls
> something like _httpClient.execute(new GetMethod(_url)) and then calls
> releaseConnection() on the GetMethod object. That's it. So how should
> I configure or use the HttpClient objects so that I won't run out of
> file handles?

Ideally speaking you could reuse the same HttpClient instance for all
your requests. If you decide to use multiple HttpClient instances, you
need to shutdown the connection manager before releasing the instance
[1]. Unless you specify a connection manager explicitly, HttpClient
would be using a SimpleHttpConnectionManager[2].

Since you are running out of handles, I am assuming you are having a
good number of calls to the server(s), and if your application is
multi-threaded, it might be worth looking at the
MultiThreadedHttpConnectionManager class [3].

> thanks
> Lowell

[1]: http://jakarta.apache.org/commons/httpclient/performance.html
[2]: http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/SimpleHttpConnectionManager.html
[3]: http://jakarta.apache.org/commons/httpclient/threading.html

Bindul Bhowmik
MindTree Consulting Ltd.

To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org

View raw message