hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Boquan Xie" <quanxi...@hotmail.com>
Subject Re: Too many file descriptors in TIME_WAIT state
Date Wed, 04 Apr 2007 19:00:02 GMT

Thanks for the replies. I do have some code between the 
getResponseBodyAsStream and releaseConnection, and I simplied it in the 
first email:

   InputStream is = postMethod.getResponseBodyAsStream();
   SAXReader reader = new SAXReader();
   Document doc = reader.read(is);


I assumed that it consumed all the data in the inputStream. and 
releaseConnection is supposed to close the inputStream too.

I tried the workarounds Roland mentioned, and added the registry entries:

TcpTimedWaitDelay (30)

Then the number of the file descriptors at state TIME_WAIT became much less 
and under control while I ran my performance test program.

Thank you all for your help!

-- Boquan

>From: "Xie, Boquan" <Boquan.Xie@cognos.com>
>To: <quanxie99@hotmail.com>
>Date: Wed, 4 Apr 2007 14:40:26 -0400
>From: William Rose <wr...@zip-it.org> Subject Re: Too many file descriptors 
>in TIME_WAIT state Date Tue, 03 Apr 2007 21:32:47 GMT
>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.
>Boquan Xie wrote:
>>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 
>>    HttpClient hClient = new HttpClient();
>>    hClient.getHostConfiguration().setHost("sottamlab1", 9300, "http");
>>    hClient.setHttpConnectionManager(connectionMgr);
>>in each of threads:
>>   while (true)
>>   {
>>      PostMethod postMethod = new 
>>      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 !

Exercise your brain! Try Flexicon. 

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

View raw message