You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Noam Berg <no...@SofaWare.com> on 2002/11/07 18:28:35 UTC

[httpclient]-timeout-> i found a small but important bug.

Hello, 
I need to use http connections with timeouts, since it is not part of the
release i downloaded 7th Nov 2002 sources, but 
using HttpClient.setTimeout didnt help. i checked out the code and find out
that when you create the sockets using host+port
it immediately connects so setting the timeout after that does not change
(at least in my case where i dont reuse them 
and its important in first connect for a timeout to be set).

The changes:
line 350:
	 _socket = new Socket();
	_socket.connect(new
java.net.InetSocketAddress(host,port),_so_timeout);
 
line 781:
	Socket s = sslSocketFactory.createSocket();
	s.connect(new java.net.InetSocketAddress(host, port), _so_timeout);
            return s;

and the whole file :
 <<HttpConnection.java>> 

i'm sorry but i dont have CVS ... 
10x.

P.S.
Another small thing (suggestion) ... 
When i first started using this package i wanted to do a very simple
httpconnection ... 
what would have help me _a lot_ would have been a few small source examples
for usage
(maybe a bit like your test classes).
10x

Noam Berg
R&D
SofaWare Technologies Ltd.
3 Hahilazon St. Ramat-Gan Israel
Tel:  +972-3-6128989 ext 102
Fax: +972-3-5755442
E-mail: noam@sofaware.com
Web: http://www.sofaware.com



Re: [httpclient]-timeout-> i found a small but important bug.

Posted by Ortwin Glück <or...@nose.ch>.
Noam,

You misunderstood the meaning of the setTimeout() method. This sets the 
SO_TIMEOUT property of a socket, which is the maximum time that must 
pass between data packets sent through this socket. If no traffic occurs 
on the socket for this duration the socket automatically disconnects.

This is very different from a connection timeout (as in your code).

Unfortunately connection timeouts are a feature of JDK 1.4 and are not 
backwards compatible to 1.3. So we can not use this feature at the moment.

There is already a feature request for this in Bugzilla:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10973
scheduled for the 2.0 release.

I feel that this is a major requirement and I can try and post a 
solution shortly.

Thanks for trying to contribute. However you are strongly encouraged to 
use CVS / diff to submit patches. Posting whole files without a diff is 
not feasible because we can not easily spot the changes. More coding 
rules can be found here:

http://jakarta.apache.org/site/getinvolved.html

Kind regards to Israel

Odi

p.s. Please post HttpClient issues directly to 
commons-httpclient-dev@jakarta.apache.org and *not* to the commons list, 
as your email may easily missed by the committers (depending on how good 
our filters are...). You can ommit the [HttpClient] prefix then. Patches 
should have the [PATCH] prefix in the subject line.

Noam Berg wrote:

> Hello,
> I need to use http connections with timeouts, since it is not part of the
> release i downloaded 7th Nov 2002 sources, but
> using HttpClient.setTimeout didnt help. i checked out the code and 
> find out
> that when you create the sockets using host+port
> it immediately connects so setting the timeout after that does not change
> (at least in my case where i dont reuse them
> and its important in first connect for a timeout to be set).
>
> The changes:
> line 350:
> 	 _socket = new Socket();
> 	_socket.connect(new
> java.net.InetSocketAddress(host,port),_so_timeout);
>
> line 781:
> 	Socket s = sslSocketFactory.createSocket();
> 	s.connect(new java.net.InetSocketAddress(host, port), _so_timeout);
>             return s;
>
> and the whole file :
>  <>
>
> i'm sorry but i dont have CVS ...
> 10x.
>
> P.S.
> Another small thing (suggestion) ...
> When i first started using this package i wanted to do a very simple
> httpconnection ...
> what would have help me _a lot_ would have been a few small source 
> examples
> for usage
> (maybe a bit like your test classes).
> 10x
>
> Noam Berg
> R&D
> SofaWare Technologies Ltd.
> 3 Hahilazon St. Ramat-Gan Israel
> Tel:  +972-3-6128989 ext 102
> Fax: +972-3-5755442
> E-mail: noam@sofaware.com
> Web: http://www.sofaware.com
>
>
>
> ------------------------------------------------------------------------
>
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail: 


-- 
_________________________________________________________________
  NOSE applied intelligence ag
                                    [www]      http://www.nose.ch
  ortwin glück                      [email] ortwin.glueck@nose.ch
  hardturmstrasse 171               [pgp key]          0x81CF3416
  8005 zurich                       [office]      +41-1-277 57 35
  switzerland                       [fax]         +41-1-277 57 12


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