Return-Path: Mailing-List: contact commons-httpclient-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-httpclient-dev@jakarta.apache.org Received: (qmail 70076 invoked from network); 2 Feb 2003 21:46:28 -0000 Received: from smtp2.clear.net.nz (203.97.37.27) by daedalus.apache.org with SMTP; 2 Feb 2003 21:46:28 -0000 Received: from mygale.fifthweb.net (apo.fifthweb.net [203.97.8.218]) by smtp2.clear.net.nz (CLEAR Net Mail) with SMTP id <0H9P002FAB5ILA@smtp2.clear.net.nz> for commons-httpclient-dev@jakarta.apache.org; Mon, 03 Feb 2003 10:46:32 +1300 (NZDT) Received: (qmail 14923 invoked from network); Sun, 02 Feb 2003 21:46:30 +0000 Received: from unknown (HELO simonxp) (10.10.10.130) by 0 with SMTP; Sun, 02 Feb 2003 21:46:30 +0000 Date: Mon, 03 Feb 2003 10:46:24 +1300 From: Simon Roberts Subject: Re: Running out of connections To: Commons HttpClient Project Message-id: <004c01c2cb04$887ebc30$820a0a0a@simonxp> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Mailer: Microsoft Outlook Express 6.00.2800.1106 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit X-Priority: 3 X-MSMail-priority: Normal References: <3E188604-3609-11D7-B3A0-00306557E112@u.washington.edu> X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N I guess the problem is really mine. I was somewhat expecting the connection to be released after it gets a "connection: close". /** * A test that illustrates the problem with connections not being recovered from a "Connection: close" response. */ public void testConnectionPool() throws IOException, HttpException { final MultiThreadedHttpConnectionManager manager = new MultiThreadedHttpConnectionManager(); HttpClient httpClient = new HttpClient(manager); httpClient.getHostConfiguration().setHost("www.slashdot.org", 80, "http"); httpClient.setHttpConnectionFactoryTimeout(2000); // wait up to 2 seconds when getting a HttpConnection for (int i = 0; i < 30; i++) { HttpMethod method = new GetMethod("http://www.slashdot.org/notfound"); int res = httpClient.executeMethod(method); // System.gc(); // method.releaseConnection(); } } Uncommenting either of the last two lines makes the problem go away... ----- Original Message ----- From: "Michael Becke" To: "Commons HttpClient Project" Sent: Sunday, February 02, 2003 6:18 AM Subject: Re: Running out of connections > Hello Simon, > > Sorry to be replying so late. Connections are released when: > > 1) the response is fully read > 2) the connection is manually released via > HttpMethod.releaseConnection() or HttpConnection.releaseConnection() > 3) the garbage collector runs and reclaims any connections that are no > longer being used > > The most reliable way is to manually release the connection after use. > This goes for successful or unsuccessful requests. Can you send a > sample of the code you are using that causes this problem? > > Mike > > On Wednesday, January 29, 2003, at 09:04 PM, Simon Roberts wrote: > > > Gidday, > > > > With the current CVS version, I seem to be having a problem where I > > run out of connections to a server. It happens if I do a bunch of > > HTTP operations that fail (404, as it happens) and the reply include a > > "Connection: close". If no garbage-collect happens then the > > connections are not freed! > > > > Shouldn't we expire them if we're running out of connections? > > > > Cheers, Simon > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org > >