Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 76740 invoked from network); 24 Feb 2005 23:23:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 24 Feb 2005 23:23:40 -0000 Received: (qmail 7709 invoked by uid 500); 24 Feb 2005 23:23:37 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 7685 invoked by uid 500); 24 Feb 2005 23:23:37 -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 7671 invoked by uid 99); 24 Feb 2005 23:23:36 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of dylans@gmail.com designates 64.233.170.204 as permitted sender) Received: from rproxy.gmail.com (HELO rproxy.gmail.com) (64.233.170.204) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 24 Feb 2005 15:23:34 -0800 Received: by rproxy.gmail.com with SMTP id a41so406560rng for ; Thu, 24 Feb 2005 15:23:32 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=lEhiuXey2tX3KrEFiobL5rra0fHCXCQ94SpaucI3EvYNaJXI/MxgWCfijV7FfCZixhrmt1irbzKTLaRoaHESXP8Y6pbuxU2dZ0laXYWjKEF/nrepwGhxgO6kvwJ+RQ9lzz57kWbcv8Wo+tlC6DZDlmPePU6lJEY2VxAI5/a6b5A= Received: by 10.38.76.59 with SMTP id y59mr119844rna; Thu, 24 Feb 2005 15:23:32 -0800 (PST) Received: by 10.38.24.70 with HTTP; Thu, 24 Feb 2005 15:23:32 -0800 (PST) Message-ID: <292e734005022415236cd1194c@mail.gmail.com> Date: Thu, 24 Feb 2005 15:23:32 -0800 From: Dylan Stamat Reply-To: Dylan Stamat To: Jakarta Commons Users List Subject: Re: Commons HttpClient: HttpClient#setConnectionTimeout In-Reply-To: <421D7C43.7000505@indra.es> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable References: <421CE076.7010307@noaa.gov> <421D333B.9010107@bancbridge.com> <421D7C43.7000505@indra.es> X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Connection Timeout is simply the length of time it takes before you receive a response. Socket Timout is the length of time it takes the host you are connecting to to actually send something back (other than the response). So, if you are connecting to a host that is supposed to do a big query and send you the results, you'd want a small connection timeout (3-5 seconds), and a larger socket timeout (5 minutes maybe), as the host may have to do a huge query before sending you the data. Cool ? Check out the below for an example. I actually just implemented this in my application, which is why it is so fresh in my head :) For example: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D // create connection defaults HttpConnectionManagerParams hmcp =3D=20 new HttpConnectionManagerParams(); hmcp.setSoTimeout(18000); hmcp.setConnectionTimeout(300); =20 SimpleHttpConnectionManager scm =3D=20 new SimpleHttpConnectionManager(); scm.setParams(hmcp); =20 // create http client HttpClient httpClient =3D new HttpClient(scm); =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D On Thu, 24 Feb 2005 08:03:31 +0100, Jos=E9 Antonio P=E9rez Testa wrote: > I think is: > client.setTimeout(5000); >=20 > Kedar Panse wrote: >=20 > > You may want to use socket timeout (setSoTimeout) not http coonection > > timeout > > > > Kedar > > > > John C Cartwright wrote: > > > >> Hello All, > >> > >> I'm attempting to throw an exception when the connection cannot be > >> established within 5 seconds (see code excerpt below). However when > >> the target host is down (doesn't respond to ping), it takes much > >> longer than 5 seconds before the exception is actually thrown. > >> > >> Can someone point out what I'm doing wrong? > >> > >> Thanks! > >> > >> -- john > >> > >> > >> HttpClient client =3D new HttpClient(); > >> HttpMethod method =3D new GetMethod(url); > >> client.setConnectionTimeout(5000); //wait 5 seconds for respon= se > >> try { > >> statusCode =3D client.executeMethod(method); > >> String responseBody =3D method.getResponseBodyAsString(); > >> } catch (Exception e){ > >> log.fatal("error reading URL",e); > >> throw new IllegalStateException ("Error reading URL"); > >> } finally { > >> method.releaseConnection(); > >> } > >> > >> --------------------------------------------------------------------- > >> 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 > > > -------------------------------------------------------------------------= ------------------------------------------ > Este correo electr+APM-nico y, en su caso, cualquier fichero anexo al mis= mo, contiene informaci+APM-n de car+AOE-cter confidencial exclusivamente di= rigida a su destinatario o destinatarios. Queda prohibida su divulgaci+APM-= n, copia o distribuci+APM-n a terceros sin la previa autorizaci+APM-n escri= ta de Indra. En el caso de haber recibido este correo electr+APM-nico por e= rror, se ruega notificar inmediatamente esta circunstancia mediante reenv+A= O0-o a la direcci+APM-n electr+APM-nica del remitente. >=20 > The information in this e-mail and in any attachments is confidential and= solely for the attention and use of the named addressee(s). You are hereby= notified that any dissemination, distribution or copy of this communicatio= n is prohibited without the prior written consent of Indra. If you have rec= eived this communication in error, please, notify the sender by reply e-mai= l >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-user-help@jakarta.apache.org >=20 > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org