Return-Path: Delivered-To: apmail-jakarta-httpclient-user-archive@www.apache.org Received: (qmail 81020 invoked from network); 3 Apr 2007 21:33:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Apr 2007 21:33:28 -0000 Received: (qmail 87747 invoked by uid 500); 3 Apr 2007 21:33:35 -0000 Delivered-To: apmail-jakarta-httpclient-user-archive@jakarta.apache.org Received: (qmail 87502 invoked by uid 500); 3 Apr 2007 21:33:34 -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 87491 invoked by uid 99); 3 Apr 2007 21:33:34 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Apr 2007 14:33:34 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [203.59.1.151] (HELO customer-domains.icp-qv1-irony11.iinet.net.au) (203.59.1.151) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Apr 2007 14:33:26 -0700 Received: from 203-214-92-246.dyn.iinet.net.au (HELO jasper.zip-it.org) ([203.214.92.246]) by iinet-mail.icp-qv1-irony11.iinet.net.au with ESMTP; 04 Apr 2007 05:33:02 +0800 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAOhkEkbL1lz2dGdsb2JhbACQCAE X-IronPort-AV: i="4.14,366,1170601200"; d="scan'208"; a="43460950:sNHT8330904" Received: from localhost (localhost.zip-it.org [127.0.0.1]) by jasper.zip-it.org (Postfix) with ESMTP id 5F7BA1B981F5 for ; Wed, 4 Apr 2007 07:30:42 +1000 (EST) Received: from jasper.zip-it.org ([127.0.0.1]) by localhost (jasper.zip-it.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 09458-06 for ; Wed, 4 Apr 2007 07:30:42 +1000 (EST) Received: from [192.168.123.6] (rover.zip-it.org [192.168.123.6]) by jasper.zip-it.org (Postfix) with ESMTP id 497171B981F4 for ; Wed, 4 Apr 2007 07:30:42 +1000 (EST) Message-ID: <4612C7FF.4040504@zip-it.org> Date: Wed, 04 Apr 2007 07:32:47 +1000 From: William Rose User-Agent: Thunderbird 2.0.0.0pre (Windows/20070402) MIME-Version: 1.0 To: HttpClient User Discussion Subject: Re: Too many file descriptors in TIME_WAIT state References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Debian amavisd-new at jasper.zip-it.org X-Virus-Checked: Checked by ClamAV on apache.org Hi there, IIRC, you should consume all the data from the input stream as well as calling releaseConnection(). So put in something like: byte[] buffer = new byte[65536]; int bytes; while( (bytes = is.read(buffer)) > 0 ) ; between the getResponseBodyAsStream and releaseConnection. cheers, Will Boquan Xie wrote: > > Hi, > > I am a new user of HttpClient and I am trying to do a performance test > which including httpclient requests. > > I have serveral threads constantly sending requests and getting > responses. In the main thread, I keep a > multithreadedhttpconnectionManager and a httpClient. the instance of > the httpclient is passed to each thread. > > MultiThreadedHttpConnectionManager connectionMgr = new > MultiThreadedHttpConnectionManager(); > HttpClient hClient = new HttpClient(); > hClient.getHostConfiguration().setHost("sottamlab1", 9300, "http"); > hClient.setHttpConnectionManager(connectionMgr); > > in each of threads: > > while (true) > { > PostMethod postMethod = new > PostMethod("http://sottamlab1:9300/p2pd/servlet/dispatch"); > > postMethod.addRequestHeader("soapaction", "someaction"); > postMethod.addRequestHeader("Content-Type", "text/xml"); > > postMethod.setRequestBody(requestBody); > this.hClient.executeMethod(postMethod); > > InputStream is = postMethod.getResponseBodyAsStream(); > > postMethod.releaseConnection(); > } > > After a very short time ( < 1 min ), running the program with 3 > threads, a large number of file descriptors is left at state TIME_WAIT > in tcpview. is this normal ? It seems to me that > httpclient/multithreadedHttpClientManager didnot reuse the connections > for me. Am I missing something in the code ? > > if I run the program with 1 thread, the problem of large number of > file descriptors in TIME_WAIT state doesnot happen. > > Please help ! > > _________________________________________________________________ > Get a FREE Web site, company branded e-mail and more from Microsoft > Office Live! http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/ > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: httpclient-user-help@jakarta.apache.org