hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
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.

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


Mime
View raw message