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:
=====================
// create connection defaults
HttpConnectionManagerParams hmcp =
new HttpConnectionManagerParams();
hmcp.setSoTimeout(18000);
hmcp.setConnectionTimeout(300);
SimpleHttpConnectionManager scm =
new SimpleHttpConnectionManager();
scm.setParams(hmcp);
// create http client
HttpClient httpClient = new HttpClient(scm);
=====================
On Thu, 24 Feb 2005 08:03:31 +0100, Jos� Antonio P�rez Testa
<[EMAIL PROTECTED]> wrote:
> I think is:
> client.setTimeout(5000);
>
> Kedar Panse wrote:
>
> > 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 = new HttpClient();
> >> HttpMethod method = new GetMethod(url);
> >> client.setConnectionTimeout(5000); //wait 5 seconds for response
> >> try {
> >> statusCode = client.executeMethod(method);
> >> String responseBody = method.getResponseBodyAsString();
> >> } catch (Exception e){
> >> log.fatal("error reading URL",e);
> >> throw new IllegalStateException ("Error reading URL");
> >> } finally {
> >> method.releaseConnection();
> >> }
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> -------------------------------------------------------------------------------------------------------------------
> Este correo electr+APM-nico y, en su caso, cualquier fichero anexo al mismo,
> contiene informaci+APM-n de car+AOE-cter confidencial exclusivamente dirigida
> a su destinatario o destinatarios. Queda prohibida su divulgaci+APM-n, copia
> o distribuci+APM-n a terceros sin la previa autorizaci+APM-n escrita de
> Indra. En el caso de haber recibido este correo electr+APM-nico por error, se
> ruega notificar inmediatamente esta circunstancia mediante reenv+AO0-o a la
> direcci+APM-n electr+APM-nica del remitente.
>
> 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 communication
> is prohibited without the prior written consent of Indra. If you have
> received this communication in error, please, notify the sender by reply
> e-mail
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]