Return-Path: Delivered-To: apmail-jakarta-httpclient-dev-archive@www.apache.org Received: (qmail 72170 invoked from network); 31 Mar 2005 14:31:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 31 Mar 2005 14:31:24 -0000 Received: (qmail 45776 invoked by uid 500); 31 Mar 2005 14:31:23 -0000 Delivered-To: apmail-jakarta-httpclient-dev-archive@jakarta.apache.org Received: (qmail 45754 invoked by uid 500); 31 Mar 2005 14:31:23 -0000 Mailing-List: contact httpclient-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "HttpClient Project" Reply-To: "HttpClient Project" Delivered-To: mailing list httpclient-dev@jakarta.apache.org Received: (qmail 45741 invoked by uid 99); 31 Mar 2005 14:31:22 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from fire.nose.ch (HELO mail.nose.ch) (195.134.131.71) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 31 Mar 2005 06:31:18 -0800 Received: (qmail 11621 invoked by uid 1010); 31 Mar 2005 16:31:11 +0200 Received: from 192.168.1.7 by chekov (envelope-from , uid 89) with qmail-scanner-1.24 (clamdscan: 0.80/585. spamassassin: 3.0.2. Clear:RC:1(192.168.1.7):. Processed in 0.037693 secs); 31 Mar 2005 14:31:11 -0000 X-Qmail-Scanner-Mail-From: ortwin.glueck@nose.ch via chekov X-Qmail-Scanner: 1.24 (Clear:RC:1(192.168.1.7):. Processed in 0.037693 secs) Received: from unknown (HELO ?192.168.1.7?) (192.168.1.7) by chekov.nose.ch with AES256-SHA encrypted SMTP; 31 Mar 2005 16:31:11 +0200 Message-ID: <424C09AE.4000400@nose.ch> Date: Thu, 31 Mar 2005 16:31:10 +0200 From: =?ISO-8859-1?Q?Ortwin_Gl=FCck?= Organization: NOSE Applied Intelligence User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: HttpClient Project Subject: Re: ExecutorService, Future, and HttpClient with a MultiThreadedHttpConnectionManager References: <20050331141744.59839.qmail@web52608.mail.yahoo.com> In-Reply-To: <20050331141744.59839.qmail@web52608.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Kent, Some possibilities: * You are leaking connections. Make sure to call releaseConnection in a finally clause that is executed unconditionally if a method was allocated. * You are running out of file descriptors. Especially under some Unix systems with many short-lived connections this can be a problem. * The priority queue of the connection manager starves because GC is deferred. This can happen when you have a large heap and the pool is exhausted before the GC ever kicked in. Some explicit calls to the GC may help. Also consider a different GC algorithm. Ortwin Gl�ck Kent Gibson wrote: > Hi-ya All > > I am probably doing something really silly, but I > decided to use the java 1.5 ExecutorService, the > Future class and a HttpClient with a > MultiThreadedHttpConnectionManager. > > The idea was that I could cancel a thread if I wanted > to. > > Anyways it runs ok, but then after x number of > connects I only get java.net.SocketTimeoutException: > Read timed out. > > I am always releasing the connection. Maybe I am even > releasing the connection after it has been released. > Could this be the problem? > > This is basically the pattern, or perhaps even > anti-pattern. > > Future futures[] = new Future[CONCURRENT_THREADS]; > RomeFeedMMThread workers[] = new > RomeFeedMMThread[CONCURRENT_THREADS]; > ExecutorService tpes = > Executors.newFixedThreadPool(CONCURRENT_THREADS); > HttpClient httpClient = new HttpClient(new > MultiThreadedHttpConnectionManager()); > > RomeFeedMMThread get = new RomeFeedMMThread(urls[i], > inputs[j], httpClient); > workers[j] = get; > futures[j] = tpes.submit(workers[j]); > > then in my thread: > > httpClient.executeMethod(get); > byte[] bytes = get.getResponseBody(); > get.releaseConnection(); > > then (still in the same thread)depending on what was > in the body (the response body is an xml file with > urls): > > loop : > GetMethod get2 = new GetMethod(url.toString()); > byte[] bytes = get2.getResponseBody(); > get2.releaseConnection(); > > whatcha think? > > regards > > kent > > > > __________________________________ > Do you Yahoo!? > Yahoo! Small Business - Try our new resources site! > http://smallbusiness.yahoo.com/resources/ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org > -- _________________________________________________________________ NOSE applied intelligence ag ortwin gl�ck [www] http://www.nose.ch software engineer hardturmstrasse 171 [pgp id] 0x81CF3416 8005 z�rich [office] +41-1-277 57 35 switzerland [fax] +41-1-277 57 12 --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org