You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ot...@ivillage.com on 2001/12/01 19:39:57 UTC

httpclient timeout

Hello,

I would imagine that this is a very frequently asked question, but I could not find any mention of it in the list archives.

Does Commons' httpclient have a way of setting a connection timeout?
I looked at the API javadocs and could not find a way to do it.

If there is no way to do it does httpclient block when it encounters super slow connections?

Thanks,
Otis

_________________________________________________________________
iVillage.com: Solutions for Your Life 
Check out the most exciting women's community on the Web   
http://www.ivillage.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: httpclient timeout

Posted by Fredrik Lindgren <fr...@chello.se>.
+1 for adding timeouts

Currently HttpClient does not seem to have a way to set the timeout. 
(I'm just a user and I might be wrong)

However it should be easy to implement since the HttpConnection uses 
Java.net.Socket inside.

The following snippet should do the trick if added to HttpConnection

/**
  * Set my {@link Socket}'s timeout, via
  * {@link Socket#setSoTimeout}.
  * @throws SocketException - if there is an error in the underlying
  * protocol, such as a TCP error.
  * @throws IllegalStateException if I am not connected
  */
public void setSoTimeout(int timeout)
		throws SocketException, IllegalStateException {
	log.debug("HttpConnection.setSoTimeout()");
	assertOpen();
	_socket.setSoTimeout(int timeout);
} 
	

Please correct me if I'm wrong, or respond with a good argument why this 
would be a bad way to do it.

An alternative to changing the public API would be to add a protected 
method getSocket() so that extending HttpConnection to support timeouts 
would be possible.

/Fredrik Lindgren	


otisg@ivillage.com wrote:

> Hello,
> 
> I would imagine that this is a very frequently asked question, but I could not find any mention of it in the list archives.
> 
> Does Commons' httpclient have a way of setting a connection timeout?
> I looked at the API javadocs and could not find a way to do it.
> 
> If there is no way to do it does httpclient block when it encounters super slow connections?
> 
> Thanks,
> Otis
> 
> _________________________________________________________________
> iVillage.com: Solutions for Your Life 
> Check out the most exciting women's community on the Web   
> http://www.ivillage.com
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>