Discussion:
[Bug-wget] How does --connect-timeout work?
Peng Yu
2018-10-24 17:12:07 UTC
Permalink
Hi,

The second command hangs forever. I am not sure what is wrong with it.
My understanding is that if I set connect-timeout short enough, wget
should fail. Could anybody let me know how to get this behavior? (See
the curl output below as a reference.)

$ time wget -qO- http://httpbin.org/get
{
"args": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "identity",
"Connection": "close",
"Host": "httpbin.org",
"User-Agent": "Wget/1.19.5 (darwin17.7.0)"
},
"origin": "165.91.49.229",
"url": "http://httpbin.org/get"
}

real 0m0.237s
user 0m0.005s
sys 0m0.006s
$ wget --connect-timeout .0001 -qO- http://httpbin.org/get
$ curl --connect-timeout .1 http://httpbin.org/get
curl: (28) Connection timed out after 100 milliseconds
--
Regards,
Peng
Tim Rühsen
2018-10-25 07:39:51 UTC
Permalink
Hi,

the default is to try 20 times with a increasing wait time inbetween
(that is documented).

Add --tries=1 and it will behave as you want.

Regards, Tim
Post by Peng Yu
Hi,
The second command hangs forever. I am not sure what is wrong with it.
My understanding is that if I set connect-timeout short enough, wget
should fail. Could anybody let me know how to get this behavior? (See
the curl output below as a reference.)
$ time wget -qO- http://httpbin.org/get
{
"args": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "identity",
"Connection": "close",
"Host": "httpbin.org",
"User-Agent": "Wget/1.19.5 (darwin17.7.0)"
},
"origin": "165.91.49.229",
"url": "http://httpbin.org/get"
}
real 0m0.237s
user 0m0.005s
sys 0m0.006s
$ wget --connect-timeout .0001 -qO- http://httpbin.org/get
$ curl --connect-timeout .1 http://httpbin.org/get
curl: (28) Connection timed out after 100 milliseconds
Loading...