Return-Path: X-Original-To: apmail-hc-httpclient-users-archive@www.apache.org Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 184FD758D for ; Mon, 26 Sep 2011 21:04:02 +0000 (UTC) Received: (qmail 16670 invoked by uid 500); 26 Sep 2011 21:04:01 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 16637 invoked by uid 500); 26 Sep 2011 21:04:01 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 16628 invoked by uid 99); 26 Sep 2011 21:04:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Sep 2011 21:04:01 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of samcrawford@gmail.com designates 209.85.210.179 as permitted sender) Received: from [209.85.210.179] (HELO mail-iy0-f179.google.com) (209.85.210.179) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Sep 2011 21:03:53 +0000 Received: by iabn5 with SMTP id n5so5217708iab.10 for ; Mon, 26 Sep 2011 14:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=b1s2lHSxV6RQlYrpu8+BGDL2Dxjp6aTFmZCh+hrI4Q4=; b=TPdEwiM0xOrCaK2szwJABbcrcHbtsE9arariutzBQDHeK6M9aQjaTjbEUElVb+5Q9E C0jtjk9ujWjHIDrqjNVbalDL/XeAYur+JnDD/s5qF9EhgNF+0aMW9TKOfO7mc4imMOOL qDiuKqUzjE6bbhLIcPClNx/HG1ecwXxQkrlew= MIME-Version: 1.0 Received: by 10.42.158.138 with SMTP id h10mr8071237icx.103.1317071012179; Mon, 26 Sep 2011 14:03:32 -0700 (PDT) Received: by 10.231.144.141 with HTTP; Mon, 26 Sep 2011 14:03:32 -0700 (PDT) In-Reply-To: References: <1317064006.551.40.camel@ubuntu> Date: Mon, 26 Sep 2011 22:03:32 +0100 Message-ID: Subject: Re: 4.1.2 http client Thread in WAITING state on getEntryBlocking From: Sam Crawford To: HttpClient User Discussion Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Yes, absolutely. Thanks, Sam On 26 September 2011 21:57, Mohit Anchlia wrote: > Thanks! should it be read on http errors too? for eg: http code 400, 500 = etc. > > On Mon, Sep 26, 2011 at 1:43 PM, Sam Crawford wro= te: >> That's correct. You have to consume the entity before the connection >> is released. See the documentation (section 1.1.5) at >> http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fundamentals= .html#d4e72 >> >> >> On 26 September 2011 20:19, Mohit Anchlia wrote= : >>> On Mon, Sep 26, 2011 at 12:06 PM, Oleg Kalnichevski = wrote: >>>> On Mon, 2011-09-26 at 09:04 -0700, Mohit Anchlia wrote: >>>>> I am using 4.1.2 and trying to figure out why my threads are all >>>>> waiting on this block. I have this code: >>>>> >>>> >>>> That's because your code is leaking connections. >>> >>> I just added this line and it resolved the issue. =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \ >>> EntityUtils.toString(entity); >>> >>> Wondering if it's necessary to read from the entity otherwise it holds >>> on to the connection. >>> >>>> >>>> Oleg >>>> >>>>> Can someone please help? >>>>> >>>>> =A0 =A0 =A0 static { >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 cm.setMaxTotal(NO_CONN*2); >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 cm.setDefaultMaxPerRoute(NO_CONN); >>>>> =A0 =A0 =A0 } >>>>> >>>>> =A0 =A0 =A0 private static ThreadSafeClientConnManager cm =3D new >>>>> ThreadSafeClientConnManager(); >>>>> >>>>> =A0 =A0 =A0 private static HttpClient httpclient =3D new DefaultHttpC= lient(cm); >>>>> >>>>> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 StringEntity stringEntity= =3D new StringEntity(data, HTTP.UTF_8); >>>>> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 httpput.setEntity(stringE= ntity); >>>>> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 HttpResponse response =3D= httpclient.execute(httpput); >>>>> >>>>> >>>>> "pool-1-thread-24" prio=3D10 tid=3D0x00002aaab4018000 nid=3D0x20df wa= iting >>>>> on condition [0x00000000446f7000] >>>>> =A0 =A0java.lang.Thread.State: WAITING (parking) >>>>> =A0 =A0 =A0 =A0 at sun.misc.Unsafe.park(Native Method) >>>>> =A0 =A0 =A0 =A0 - parking to wait for =A0<0x000000061d5866f0> (a >>>>> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject= ) >>>>> =A0 =A0 =A0 =A0 at java.util.concurrent.locks.LockSupport.park(LockSu= pport.java:158) >>>>> =A0 =A0 =A0 =A0 at java.util.concurrent.locks.AbstractQueuedSynchroni= zer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987) >>>>> =A0 =A0 =A0 =A0 at org.apache.http.impl.conn.tsccm.WaitingThread.awai= t(WaitingThread.java:158) >>>>> =A0 =A0 =A0 =A0 at org.apache.http.impl.conn.tsccm.ConnPoolByRoute.ge= tEntryBlocking(ConnPoolByRoute.java:403) >>>>> =A0 =A0 =A0 =A0 at org.apache.http.impl.conn.tsccm.ConnPoolByRoute$1.= getPoolEntry(ConnPoolByRoute.java:300) >>>>> =A0 =A0 =A0 =A0 at org.apache.http.impl.conn.tsccm.ThreadSafeClientCo= nnManager$1.getConnection(ThreadSafeClientConnManager.java:224) >>>>> =A0 =A0 =A0 =A0 at org.apache.http.impl.client.DefaultRequestDirector= .execute(DefaultRequestDirector.java:401) >>>>> =A0 =A0 =A0 =A0 at org.apache.http.impl.client.AbstractHttpClient.exe= cute(AbstractHttpClient.java:820) >>>>> =A0 =A0 =A0 =A0 at org.apache.http.impl.client.AbstractHttpClient.exe= cute(AbstractHttpClient.java:754) >>>>> =A0 =A0 =A0 =A0 at org.apache.http.impl.client.AbstractHttpClient.exe= cute(AbstractHttpClient.java:732) >>>>> =A0 =A0 =A0 =A0 at com.intuit.gluster.stress.ClientPost.doPut(ClientP= ost.java:135) >>>>> =A0 =A0 =A0 =A0 at com.intuit.gluster.stress.InsertHttpCommand.call(I= nsertHttpCommand.java:142) >>>>> =A0 =A0 =A0 =A0 at com.intuit.gluster.stress.InsertHttpCommand.call(I= nsertHttpCommand.java:1) >>>>> =A0 =A0 =A0 =A0 at java.util.concurrent.FutureTask$Sync.innerRun(Futu= reTask.java:303) >>>>> =A0 =A0 =A0 =A0 at java.util.concurrent.FutureTask.run(FutureTask.jav= a:138) >>>>> =A0 =A0 =A0 =A0 at java.util.concurrent.ThreadPoolExecutor$Worker.run= Task(ThreadPoolExecutor.java:886) >>>>> =A0 =A0 =A0 =A0 at java.util.concurrent.ThreadPoolExecutor$Worker.run= (ThreadPoolExecutor.java:908) >>>>> =A0 =A0 =A0 =A0 at java.lang.Thread.run(Thread.java:662) >>>>> >>>>> >>>>> jars in my classpath: >>>>> >>>>> >>>>> ls -ltr jars >>>>> total 1572 >>>>> -rwx------ 1 root root =A060686 Jan 21 =A02011 commons-logging-1.1.1.= jar >>>>> -rwx------ 1 root root =A058160 Jan 21 =A02011 commons-codec-1.4.jar >>>>> -rwx------ 1 root root 181200 Jul 10 12:02 httpcore-4.1.2.jar >>>>> -rwx------ 1 root root 261809 Jul 21 11:58 commons-lang-2.4.jar >>>>> -rwx------ 1 root root =A025496 Jul 21 11:58 slf4j-api-1.6.1.jar >>>>> -rwx------ 1 root root 481535 Jul 21 11:58 log4j-1.2.16.jar >>>>> -rwx------ 1 root root =A0 9753 Jul 21 11:58 slf4j-log4j12-1.6.1.jar >>>>> -rwx------ 1 root root 105799 Jul 29 22:54 httpclient-cache-4.1.2.jar >>>>> -rwx------ 1 root root 352254 Jul 29 22:54 httpclient-4.1.2.jar >>>>> -rwx------ 1 root root =A026890 Jul 29 22:54 httpmime-4.1.2.jar >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org >>>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org >>>>> >>>> >>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org >>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org >>>> >>>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org >>> For additional commands, e-mail: httpclient-users-help@hc.apache.org >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org >> For additional commands, e-mail: httpclient-users-help@hc.apache.org >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org > For additional commands, e-mail: httpclient-users-help@hc.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org For additional commands, e-mail: httpclient-users-help@hc.apache.org