You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Mehrshad Setayesh <me...@collectiveintellect.com> on 2005/12/11 16:46:53 UTC

Read blocking on GetMethod's getResponseBody

Hello:

I am using commons-httpclient-3.0-rc3.

Every once in a while my getResponseBody call on a GetMethod blocks
indefinitely. I have tried using getResponseBodyAsStream but the call now
blocks on read method.

How can I specify a timeout value, so if no bytes are received within a
timeframe, timeout occurs and method exits.

Regards
Mehrshad


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


RE: Read blocking on GetMethod's getResponseBody

Posted by Mehrshad Setayesh <me...@collectiveintellect.com>.
I used option 1 and so far so good. Thanks.

Regards
Mehrshad

-----Original Message-----
From: Michael Becke [mailto:mbecke@gmail.com] 
Sent: Sunday, December 11, 2005 1:22 PM
To: HttpClient Project
Subject: Re: Read blocking on GetMethod's getResponseBody

Hi Mehrshad,

You have two options:

 1) Set the socket timeout value.  This configures how long the socket
will block for any one read operation.  It does not however limit the
total time taken when executing a method.

http.socket.timeout -
<http://jakarta.apache.org/commons/httpclient/preference-api.html#HTTP%20con
nection%20parameters>

2) Call HttpMethod.abort() from a second thread after the desired wait
time has been reched.

Mike

On 12/11/05, Mehrshad Setayesh <me...@collectiveintellect.com> wrote:
> Hello:
>
> I am using commons-httpclient-3.0-rc3.
>
> Every once in a while my getResponseBody call on a GetMethod blocks
> indefinitely. I have tried using getResponseBodyAsStream but the call now
> blocks on read method.
>
> How can I specify a timeout value, so if no bytes are received within a
> timeframe, timeout occurs and method exits.
>
> Regards
> Mehrshad
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: Read blocking on GetMethod's getResponseBody

Posted by Michael Becke <mb...@gmail.com>.
Hi Mehrshad,

You have two options:

 1) Set the socket timeout value.  This configures how long the socket
will block for any one read operation.  It does not however limit the
total time taken when executing a method.

http.socket.timeout -
<http://jakarta.apache.org/commons/httpclient/preference-api.html#HTTP%20connection%20parameters>

2) Call HttpMethod.abort() from a second thread after the desired wait
time has been reched.

Mike

On 12/11/05, Mehrshad Setayesh <me...@collectiveintellect.com> wrote:
> Hello:
>
> I am using commons-httpclient-3.0-rc3.
>
> Every once in a while my getResponseBody call on a GetMethod blocks
> indefinitely. I have tried using getResponseBodyAsStream but the call now
> blocks on read method.
>
> How can I specify a timeout value, so if no bytes are received within a
> timeframe, timeout occurs and method exits.
>
> Regards
> Mehrshad
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org