Return-Path: Delivered-To: apmail-jakarta-httpclient-user-archive@www.apache.org Received: (qmail 45050 invoked from network); 15 Feb 2007 19:52:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Feb 2007 19:52:14 -0000 Received: (qmail 11650 invoked by uid 500); 15 Feb 2007 19:52:20 -0000 Delivered-To: apmail-jakarta-httpclient-user-archive@jakarta.apache.org Received: (qmail 11636 invoked by uid 500); 15 Feb 2007 19:52:20 -0000 Mailing-List: contact httpclient-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: "HttpClient User Discussion" Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-user@jakarta.apache.org Received: (qmail 11625 invoked by uid 99); 15 Feb 2007 19:52:20 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Feb 2007 11:52:20 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of bindulbhowmik@gmail.com designates 64.233.184.234 as permitted sender) Received: from [64.233.184.234] (HELO wr-out-0506.google.com) (64.233.184.234) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Feb 2007 11:52:10 -0800 Received: by wr-out-0506.google.com with SMTP id 67so1191427wri for ; Thu, 15 Feb 2007 11:51:49 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Iu9DlZbjE5SRUcxeor79PjaVDkawQwPL5WyWlXY8PmgLAMA/sGYCDEhFFCmSc+yQ602ItwaGyp9uxfblFLKBXbWusviRH+tEUwO8TaCsr2ojCHXQ/PxVrmm5EQ4e1orb+PsTxh7k+AASaBIDHDFcHNEvt1D+JgJ8pyCJhxlfZr8= Received: by 10.114.199.1 with SMTP id w1mr1410889waf.1171569108943; Thu, 15 Feb 2007 11:51:48 -0800 (PST) Received: by 10.115.107.5 with HTTP; Thu, 15 Feb 2007 11:51:48 -0800 (PST) Message-ID: <882a6a7e0702151151o243ca2bdv89bfd2bcf91c1bef@mail.gmail.com> Date: Thu, 15 Feb 2007 12:51:48 -0700 From: "Bindul Bhowmik" To: "HttpClient User Discussion" Subject: Re: Running out of file handles In-Reply-To: <8a6db32b0702151052o217da5bfr1ffdf8e93ec2a732@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <8a6db32b0702151052o217da5bfr1ffdf8e93ec2a732@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Lowell, On 2/15/07, Lowell Kirsh 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