Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 36460 invoked from network); 2 Mar 2005 21:45:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 2 Mar 2005 21:45:54 -0000 Received: (qmail 35723 invoked by uid 500); 2 Mar 2005 21:45:51 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 35674 invoked by uid 500); 2 Mar 2005 21:45:50 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 35661 invoked by uid 99); 2 Mar 2005 21:45:50 -0000 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from mail2.bluewin.ch (HELO mail2.bluewin.ch) (195.186.4.73) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 02 Mar 2005 13:45:49 -0800 Received: from xbox.localdomain (83.79.7.111) by mail2.bluewin.ch (Bluewin AG 7.0.035) id 41DEA58B005482FF for commons-user@jakarta.apache.org; Wed, 2 Mar 2005 21:45:45 +0000 Received: from 192.168.0.2 (unknown [192.168.0.2]) by xbox.localdomain (Postfix) with ESMTP id B8484B6ECC for ; Wed, 2 Mar 2005 22:45:51 +0100 (CET) Subject: Re: Commons HttpClient: HttpClient#setConnectionTimeout From: Oleg Kalnichevski To: Jakarta Commons Users List In-Reply-To: References: <421CE076.7010307@noaa.gov> <421D333B.9010107@bancbridge.com> <421D7C43.7000505@indra.es> <292e734005022415236cd1194c@mail.gmail.com> Content-Type: text/plain Date: Wed, 02 Mar 2005 22:45:45 +0100 Message-Id: <1109799945.7782.6.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-3) Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Works for me as expected. I get a socket timeout exception in 5 secs [DEBUG] header - ->> "GET / HTTP/1.1[\r][\n]" [DEBUG] header - ->> "User-Agent: Jakarta Commons-HttpClient/3.0-rc1 [\r][\n]" [DEBUG] header - ->> "Host: localhost:12345[\r][\n]" [DEBUG] header - ->> "[\r][\n]" Exception in thread "main" java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) ... I am running Fedora Core 3 Linux with the kernel 2.6.10-1.766_FC3smp and Java 1.4.2-b28. This seems to be related to your specific platform setup Oleg On Tue, 2005-03-01 at 17:55 -0500, Scott Heaberlin wrote: > Not to bring this thread back up, but I am having a hard time getting > this to work (tried both 2.0.2 and 3.0-rc1) > > > //input = my non-null string > HttpClient myClient = new HttpClient(); > PostMethod post = new PostMethod("http://localhost:12345"); > post.setRequestBody(input); > post.setRequestContentLength(input.length()); > httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000L); > httpClient.getHttpConnectionManager().getParams().setSoTimeout(5000L); > httpClient.executeMethod(post); > String response = httpMethod.getResponseBodyAsString(); > > > Run the netcat command, `nc -l -p 12345` (that's a lower case -L) locally. > Now - run the above snippet. You'll see in your netcat console > everything httpclient sends... but don't touch anything. Wait 5000 > milliseconds. Wait 10,000 milliseconds. Wait indefinitely... > > On my machine (JRE 1.4.2_03) this never ever returns. If I Control-C > (punt) the netcat command, my java app *immediately* receives: > java.net.ConnectException: Connection refused: connect > > I am trying to troubleshoot a situation in an application which has > its own "timeout" configuration which is passed directly to > httpclient, but we are seeing in our logs evidence that this timeout > is apparently having no effect and certain http requests we make are > at the mercy of the responding web server. > > Any thoughts? Of course the above code sample only works with 3.0+. > I was previously (2.0.2) using the equivalent methods (now deprecated) > directly on the HttpClient instance: > > httpClient.setConnectionTimeout(5000L); > httpClient.setTimeout(5000L); > > > Any thoughts? Your help is greatly appreciated, > > -Scott > > > Scott Heaberlin > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-user-help@jakarta.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org