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 080BF9799 for ; Sat, 26 Nov 2011 19:13:15 +0000 (UTC) Received: (qmail 55684 invoked by uid 500); 26 Nov 2011 19:13:14 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 55650 invoked by uid 500); 26 Nov 2011 19:13:14 -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 55642 invoked by uid 99); 26 Nov 2011 19:13:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 26 Nov 2011 19:13:14 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests=FREEMAIL_FROM,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.26 as permitted sender) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 26 Nov 2011 19:13:10 +0000 Received: from isper.nabble.com ([192.168.236.156]) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1RUNg9-0001cl-EV for httpclient-users@hc.apache.org; Sat, 26 Nov 2011 11:12:49 -0800 Message-ID: <32876975.post@talk.nabble.com> Date: Sat, 26 Nov 2011 11:12:49 -0800 (PST) From: richevo To: httpclient-users@hc.apache.org Subject: Re: HttpAsyncClient 4.0-alpha3 and timeouts In-Reply-To: <1322328955.3727.2.camel@ubuntu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: richyevans@gmail.com References: <32874649.post@talk.nabble.com> <20111124110519.GA16019@ok2cons2.nine.ch> <32875604.post@talk.nabble.com> <20111124222908.GA32209@ok2cons2.nine.ch> <32875719.post@talk.nabble.com> <1322328955.3727.2.camel@ubuntu> I'm talking about response timeouts. I tried just using HttpCore and that respected the response timeouts for my test. I used the NHttpClient example. It could be an option to just use HttpCore but I was interested in using the higher level connection support. All I want to do is to be able to configure a response timeout of x seconds, so if the web service takes more than x seconds to respond I get a timeout. So the socket remains connected at all times but there is no response. I suspect that I'm not explaining myself very well. olegk wrote: > > On Thu, 2011-11-24 at 15:38 -0800, richev wrote: >> Okay. Can you tell me how I code the client so that it does timeout after >> x >> seconds? I assumed that was what I was doing with the timeout options in >> my >> code that I posted. >> > > Are you talking about connect timeout or socket timeout? If you mean the > latter, most likely your expectation is simply wrong. Please look up a > definition of the socket timeout and what exactly it signifies. > > Oleg > >> >> olegk wrote: >> > >> > On Thu, Nov 24, 2011 at 12:42:35PM -0800, richevo wrote: >> >> >> >> I hope this makes it clear. Apologies for the 4 posts with the same >> >> question, >> >> don't know what happened! >> >> >> >> >> >> >> java.util.logging.Logger.getLogger("org.apache.http.wire").setLevel(java.util.logging.Level.FINEST); >> >> >> java.util.logging.Logger.getLogger("org.apache.http.headers").setLevel(java.util.logging.Level.FINEST); >> >> System.setProperty("org.apache.commons.logging.Log", >> >> "org.apache.commons.logging.impl.SimpleLog"); >> >> >> System.setProperty("org.apache.commons.logging.simplelog.showdatetime", >> >> "true"); >> >> >> System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", >> >> "debug"); >> >> >> System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http", >> >> "debug"); >> >> >> System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.headers", >> >> "debug"); >> >> >> >> HttpClient setup -> >> >> HttpAsyncClient httpclient = new DefaultHttpAsyncClient(); >> >> httpclient.getParams() >> >> .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 3000) >> >> .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, >> >> 3000) >> >> .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, >> 8 * >> >> 1024) >> >> .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, >> true); >> >> >> >> Wire log-> >> >> >> >> 2011/11/24 20:37:21:885 GMT [DEBUG] >> PoolingAsyncClientConnectionManager - >> >> Connection request: [route: >> HttpRoute[{}->http://localhost:8080]][total >> >> kept >> >> alive: 0; route allocated: 0 of 2; total allocated: 0 of 20] >> >> 2011/11/24 20:37:21:930 GMT [DEBUG] >> PoolingAsyncClientConnectionManager - >> >> Connection leased: [id: 0][route: >> >> HttpRoute[{}->http://localhost:8080]][total kept alive: 0; route >> >> allocated: >> >> 1 of 2; total allocated: 0 of 20] >> >> 2011/11/24 20:37:21:936 GMT [DEBUG] DefaultHttpAsyncClient - >> Connection >> >> request suceeded: >> >> [id:0][route:HttpRoute[{}->http://localhost:8080]][state:null] >> >> 2011/11/24 20:37:21:981 GMT [DEBUG] IOSessionImpl - http-outgoing-0 >> >> 127.0.0.1:61717<->127.0.0.1:8080[ACTIVE][rw:]: Event set [w] >> >> 2011/11/24 20:37:21:982 GMT [DEBUG] HttpAsyncClientProtocolHandler - >> >> http-outgoing-0 [ACTIVE]: Connected >> >> 2011/11/24 20:37:21:984 GMT [DEBUG] HttpAsyncClientProtocolHandler - >> >> http-outgoing-0 [ACTIVE] Request ready >> >> 2011/11/24 20:37:21:987 GMT [DEBUG] RequestAddCookies - CookieSpec >> >> selected: >> >> best-match >> >> 2011/11/24 20:37:22:006 GMT [DEBUG] RequestAuthCache - Auth cache not >> set >> >> in >> >> the context >> >> 2011/11/24 20:37:22:006 GMT [DEBUG] DefaultHttpAsyncClient - Attempt 1 >> to >> >> execute request >> >> 2011/11/24 20:37:22:006 GMT [DEBUG] headers - http-outgoing-0 >> GET >> >> /Test2/rest/world HTTP/1.1 >> >> 2011/11/24 20:37:22:007 GMT [DEBUG] headers - http-outgoing-0 >> Host: >> >> localhost:8080 >> >> 2011/11/24 20:37:22:007 GMT [DEBUG] headers - http-outgoing-0 >> >> >> Connection: >> >> Keep-Alive >> >> 2011/11/24 20:37:22:007 GMT [DEBUG] headers - http-outgoing-0 >> >> >> User-Agent: >> >> Apache-HttpAsyncClient/4.0-alpha3 (java 1.5) >> >> 2011/11/24 20:37:22:009 GMT [DEBUG] IOSessionImpl - http-outgoing-0 >> >> 127.0.0.1:61717<->127.0.0.1:8080[ACTIVE][rw:]: Event set [w] >> >> 2011/11/24 20:37:22:014 GMT [DEBUG] IOSessionImpl - http-outgoing-0 >> >> 127.0.0.1:61717<->127.0.0.1:8080[ACTIVE][rw:w]: 138 bytes written >> >> 2011/11/24 20:37:22:014 GMT [DEBUG] wire - http-outgoing-0 >> "GET >> >> /Test2/rest/world HTTP/1.1[\r][\n]" >> >> 2011/11/24 20:37:22:014 GMT [DEBUG] wire - http-outgoing-0 >> "Host: >> >> localhost:8080[\r][\n]" >> >> 2011/11/24 20:37:22:014 GMT [DEBUG] wire - http-outgoing-0 >> >> >> "Connection: >> >> Keep-Alive[\r][\n]" >> >> 2011/11/24 20:37:22:015 GMT [DEBUG] wire - http-outgoing-0 >> >> >> "User-Agent: >> >> Apache-HttpAsyncClient/4.0-alpha3 (java 1.5)[\r][\n]" >> >> 2011/11/24 20:37:22:015 GMT [DEBUG] wire - http-outgoing-0 >> >> "[\r][\n]" >> >> 2011/11/24 20:37:22:015 GMT [DEBUG] IOSessionImpl - http-outgoing-0 >> >> 127.0.0.1:61717<->127.0.0.1:8080[ACTIVE][r:w]: Event cleared [w] >> >> 2011/11/24 20:37:22:015 GMT [DEBUG] HttpAsyncClientProtocolHandler - >> >> http-outgoing-0 [ACTIVE] Request ready >> >> 2011/11/24 20:37:46:720 GMT [DEBUG] IOSessionImpl - http-outgoing-0 >> >> 127.0.0.1:61717<->127.0.0.1:8080[ACTIVE][r:r]: 439 bytes read >> >> 2011/11/24 20:37:46:720 GMT [DEBUG] wire - http-outgoing-0 << >> "HTTP/1.1 >> >> 200 >> >> OK[\r][\n]" >> >> 2011/11/24 20:37:46:720 GMT [DEBUG] wire - http-outgoing-0 << "Server: >> >> Apache-Coyote/1.1[\r][\n]" >> >> 2011/11/24 20:37:46:720 GMT [DEBUG] wire - http-outgoing-0 << >> >> "Content-Type: >> >> application/atom+xml[\r][\n]" >> >> 2011/11/24 20:37:46:721 GMT [DEBUG] wire - http-outgoing-0 << >> >> "Content-Length: 299[\r][\n]" >> >> 2011/11/24 20:37:46:721 GMT [DEBUG] wire - http-outgoing-0 << "Date: >> Thu, >> >> 24 >> >> Nov 2011 20:37:46 GMT[\r][\n]" >> >> 2011/11/24 20:37:46:721 GMT [DEBUG] wire - http-outgoing-0 << >> "[\r][\n]" >> >> 2011/11/24 20:37:46:722 GMT [DEBUG] wire - http-outgoing-0 << "> >> version="1.0" encoding="UTF-8" standalone="yes"?>> >> xmlns="http://www.w3.org/2005/Atom" >> >> xmlns:ns2="http://a9.com/-/spec/opensearch/1.1/" >> >> >> xmlns:ns3="http://www.w3.org/1999/xhtml">helloworld:12011-11-24T20:37:46.708Z> >> type="text">Hello World!" >> >> 2011/11/24 20:37:46:732 GMT [DEBUG] headers - http-outgoing-0 << >> HTTP/1.1 >> >> 200 OK >> >> 2011/11/24 20:37:46:732 GMT [DEBUG] headers - http-outgoing-0 << >> Server: >> >> Apache-Coyote/1.1 >> >> 2011/11/24 20:37:46:732 GMT [DEBUG] headers - http-outgoing-0 << >> >> Content-Type: application/atom+xml >> >> 2011/11/24 20:37:46:732 GMT [DEBUG] headers - http-outgoing-0 << >> >> Content-Length: 299 >> >> 2011/11/24 20:37:46:732 GMT [DEBUG] headers - http-outgoing-0 << Date: >> >> Thu, >> >> 24 Nov 2011 20:37:46 GMT >> >> 2011/11/24 20:37:46:737 GMT [DEBUG] HttpAsyncClientProtocolHandler - >> >> http-outgoing-0 [ACTIVE] Response received >> >> 2011/11/24 20:37:46:737 GMT [DEBUG] DefaultHttpAsyncClient - Response: >> >> HTTP/1.1 200 OK >> >> 2011/11/24 20:37:46:742 GMT [DEBUG] HttpAsyncClientProtocolHandler - >> >> http-outgoing-0 [ACTIVE] Input ready [content length: 299; pos: 0; >> >> completed: false] >> >> 2011/11/24 20:37:46:742 GMT [DEBUG] DefaultHttpAsyncClient - Response >> >> fully >> >> read >> >> GET http://localhost:8080/Test2/rest/world HTTP/1.1->HTTP/1.1 200 OK >> >> 2011/11/24 20:37:46:749 GMT [DEBUG] DefaultHttpAsyncClient - >> Connection >> >> can >> >> be kept alive indefinitely >> >> 2011/11/24 20:37:46:749 GMT [DEBUG] DefaultHttpAsyncClient - Response >> >> processed >> >> 2011/11/24 20:37:46:750 GMT [DEBUG] >> PoolingAsyncClientConnectionManager - >> >> Connection [id: 0][route: HttpRoute[{}->http://localhost:8080]] can be >> >> kept >> >> alive indefinitely >> >> 2011/11/24 20:37:46:750 GMT [DEBUG] >> PoolingAsyncClientConnectionManager - >> >> Connection released: [id: 0][route: >> >> HttpRoute[{}->http://localhost:8080]][total kept alive: 1; route >> >> allocated: >> >> 1 of 2; total allocated: 1 of 20] >> >> 2011/11/24 20:37:46:751 GMT [DEBUG] >> PoolingAsyncClientConnectionManager - >> >> Connection manager is shutting down >> >> 2011/11/24 20:37:46:751 GMT [DEBUG] IOSessionImpl - http-outgoing-0 >> >> 127.0.0.1:61717<->127.0.0.1:8080[ACTIVE][r:r]: Shutdown >> >> 2011/11/24 20:37:46:753 GMT [DEBUG] IOSessionImpl - http-outgoing-0 >> >> 127.0.0.1:61717<->127.0.0.1:8080[CLOSED][]: Shutdown >> >> Done >> >> 2011/11/24 20:37:46:754 GMT [DEBUG] HttpAsyncClientProtocolHandler - >> >> http-outgoing-0 [CLOSED]: Disconnected >> >> 2011/11/24 20:37:46:756 GMT [DEBUG] >> PoolingAsyncClientConnectionManager - >> >> Connection manager shut down >> >> >> >> >> > >> > And what exactly is the problem here? I see nothing wrong here. I see >> no >> > reason why the connection should time out. >> > >> > Oleg >> > >> >> >> >> >> >> >> >> >> >> >> >> >> >> olegk wrote: >> >> > >> >> > On Wed, Nov 23, 2011 at 03:19:16PM -0800, richevo wrote: >> >> >> >> >> >> I am using the latest HttpAsync library 4. alpha3 >> >> >> >> >> >> Is there an issue where the timeout for the connection is not >> >> respected? >> >> >> I >> >> >> have set the timeout to 10 seconds and call a web service that >> takes a >> >> >> minute to respond. I never experience a timeout. The >> AsyncHttpClient >> >> >> waits >> >> >> forever. >> >> >> >> >> >> I've configured the timeouts as per the example code in Async. >> >> >> >> >> >> Is it obvious what I'm doing wrong? >> >> > >> >> > Please post a wire / context log of the session. >> >> > >> >> > Oleg >> >> > >> >> > >> --------------------------------------------------------------------- >> >> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org >> >> > For additional commands, e-mail: httpclient-users-help@hc.apache.org >> >> > >> >> > >> >> > >> >> >> >> -- >> >> View this message in context: >> >> >> http://old.nabble.com/HttpAsyncClient-4.0-alpha3-and-timeouts-tp32874649p32875604.html >> >> Sent from the HttpClient-User mailing list archive at Nabble.com. >> >> >> >> >> >> --------------------------------------------------------------------- >> >> 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 > > > -- View this message in context: http://old.nabble.com/HttpAsyncClient-4.0-alpha3-and-timeouts-tp32874649p32876975.html Sent from the HttpClient-User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org For additional commands, e-mail: httpclient-users-help@hc.apache.org