wget using --timeout and --tries together - linux

How long would you expect this command to take before exiting?
wget --timeout=1 --tries=2 "http://www.google.com:81/not-there"
I would expect a timeout of 1 seconds and 2 tries would mean 2 seconds, but it takes 6.025 seconds
wget --timeout=1 --tries=2 "http://www.google.com:81/not-there"
--2017-04-27 16:49:12--http://www.google.com:81/not-there
Resolving www.google.com (www.google.com)... 209.85.203.105, 209.85.203.103, 209.85.203.99, ...
Connecting to www.google.com (www.google.com)|209.85.203.105|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.103|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.99|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.104|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.106|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.147|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|2a00:1450:4009:80d::2004|:81... failed: Network is unreachable.
I don't know why it tries 6 times before quitting.
It seems like tries is for retrying. If I set --retry-connrefused it at least does the retry, but still the total time taken isn't what I would expect. I'd like to be able to decide how many times it should try on a timeout.
Edit:
After a suggestion from #Socowi I tried using waitretry in combination with retry-connrefused and got the same behaviour:
$ wget --timeout=1 --waitretry=0 --tries=2 --retry-connrefused "http://www.google.com:81/not-there"
--2017-04-27 20:29:47-- http://www.google.com:81/not-there
Resolving www.google.com (www.google.com)... 2a00:1450:400b:c00::68, 209.85.203.99, 209.85.203.147, ...
Connecting to www.google.com (www.google.com)|2a00:1450:400b:c00::68|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.99|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.147|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.103|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.104|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.106|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.105|:81... failed: Connection timed out.
Retrying.
--2017-04-27 20:29:54-- (try: 2) http://www.google.com:81/not-there
Connecting to www.google.com (www.google.com)|2a00:1450:400b:c00::68|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.99|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.147|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.103|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.104|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.106|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.105|:81... failed: Connection timed out.
Giving up.
Edit Two
I was really confused when two identical commands behaved differently.
root#8c59d6dd05fe:/var/www/html# wget --timeout=1 --waitretry=0 --tries=2 --retry-connrefused "http://www.google.com:81/not-there"
converted 'http://www.google.com:81/not-there' (ANSI_X3.4-1968) -> 'http://www.google.com:81/not-there' (UTF-8)
--2017-04-27 19:50:28-- http://www.google.com:81/not-there
Resolving www.google.com (www.google.com)... 216.58.211.164, 2a00:1450:4009:805::2004
Connecting to www.google.com (www.google.com)|216.58.211.164|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|2a00:1450:4009:805::2004|:81... failed: Cannot assign requested address.
Retrying.
--2017-04-27 19:50:29-- (try: 2) http://www.google.com:81/not-there
Connecting to www.google.com (www.google.com)|216.58.211.164|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|2a00:1450:4009:805::2004|:81... failed: Cannot assign requested address.
Giving up.
root#8c59d6dd05fe:/var/www/html# wget --timeout=1 --waitretry=0 --tries=2 --retry-connrefused "http://www.google.com:81/not-there"
converted 'http://www.google.com:81/not-there' (ANSI_X3.4-1968) -> 'http://www.google.com:81/not-there' (UTF-8)
--2017-04-27 19:50:35-- http://www.google.com:81/not-there
Resolving www.google.com (www.google.com)... 209.85.203.104, 209.85.203.147, 209.85.203.106, ...
Connecting to www.google.com (www.google.com)|209.85.203.104|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.147|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.106|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.103|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.105|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.99|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|2a00:1450:400b:c03::68|:81... failed: Cannot assign requested address.
Retrying.
--2017-04-27 19:50:41-- (try: 2) http://www.google.com:81/not-there
Connecting to www.google.com (www.google.com)|209.85.203.104|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.147|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.106|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.103|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.105|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.99|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|2a00:1450:400b:c03::68|:81... failed: Cannot assign requested address.
Giving up.
I thought I was going a bit crazy, but it was only when #Socowi pointed out in the comments that the IPs each retry were different that it clicked. It depends on the number of possible IPs being returned. The magic number 7 (retries) I was seeing was number the IP options. When I just choose one specific IP it only tries it once.

Wrong Number of Retries
Your wget seems to resolve the URL to multiple IP addresses as seen in the second line of your wget's output. Each IP is then tested with the specified timeout. Unfortunately I haven't found any options to limit the DNS lookup to one address or set a total timeout for all IPs together. But you could try to use "<googles ip address>:81/not-there" instead of the domain name.
To automatically resolve the domain to a single IP address you can use
wget "http://$(getent hosts www.google.com | sed 's/ .*//;q'):81/not-there"
Seemingly Too Long Timeout
As you already found out, setting --retry-connrefused lets wget retry even after a »connection refused« error. The specified timeout is used for each retry, but between the retries there will be a pause which gets longer after each retry.
Example
wget --timeout=1 --tries=5 --retry-connrefused URL
does something like
try to connect for 1 second
failed -> wait 1 second
try to connect for 1 second
failed -> wait 2 seconds
try to connect for 1 second
failed -> wait 3 second
try to connect for 1 second
failed -> wait 4 second
try to connect for 1 second
Therefore the command takes tries * timeout + 1 + 2 + ... + (tries - 1) seconds. This behavior is specified in man wget under the option, which allows you to change it :)
--waitretry=seconds
If you don't want Wget to wait between every retrieval, but only
between retries of failed downloads, you can use this option. Wget
will use linear backoff, waiting 1 second after the first failure
on a given file, then waiting 2 seconds after the second failure on
that file, up to the maximum number of seconds you specify.
By default, Wget will assume a value of 10 seconds.
I think you wanted to use something like
wget --timeout=1 --waitretry=0 --tries=5 --retry-connrefused URL
which eliminates the pause between two retries, resulting in a total time of timeout * tries.

Related

rafthttp: dial tcp timeout on etcd 3-node cluster creation

I don't have an access to the etcd part of the project's source code, however I do have access to the /var/log/syslog.
The goal is to setup up 3-node cluster.
(1)The very first etcd error that comes up is:
rafthttp: failed to dial 76e7ffhh20007a98 on stream MsgApp v2 (dial tcp 10.0.0.134:2380: i/o timeout)
Before continuing, I would say that I can ping all three nodes from each of the nodes. As well as I have tried to open the 2380 TCP ports and still no success - same error.
(2)So, before that error I had following messages from the etcd, which in my opinion confirm that cluster is setup correctly:
etcdserver/membership: added member 76e7ffhh20007a98 [https://server2:2380]
etcdserver/membership: added member 222e88db3803e816 [https://server1:2380]
etcdserver/membership: added member 999115e00e17123d [https://server3:2380]
In /etc/hosts file these DNS names are resolved as:
server2 10.0.0.135
server1 10.0.0.134
server3 10.0.0.136
(3)The initial setup, however (on each nodes looks like this):
embed: listening for peers on https://127.0.0.1:2380
embed: listening for client requests on 127.0.0.1:2379
So, to sum up, each node have got this initial setup log (3) and then adds members (2) then once these steps are done it fails with (1). As I know the etcd cluster creation is following this pattern: https://etcd.io/docs/v3.5/tutorials/how-to-setup-cluster/
Without knowing the source code is really hard to debug, however maybe some ideas on the error and what could cause it?
UPD: etcdctl cluster-health output (ETCDCTL_ENDPOINT is exported):
cluster may be unhealthy: failed to list members Error: client: etcd
cluster is unavailable or misconfigured; error #0: client: endpoint
http://127.0.0.1:2379 exceeded header timeout ; error #1: dial tcp
127.0.0.1:4001: connect: connection refused
error #0: client: endpoint http://127.0.0.1:2379 exceeded header
timeout error #1: dial tcp 127.0.0.1:4001: connect: connection refused

server closed the connection unexpectedly python

server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
and when I run with docker exec ...
psql: error: could not connect to server: could not translate
host name "potgres" to address: No address associated with hostname
my port seems like that :
0.0.0.0:5431->5431/tcp, 5432/tcp
even when I change port number in file.yml , there is nothing happen!
Are you sure you spelled your hostname correctly?
psql: error: could not connect to server: could not translate
host name "potgres" to address: No address associated with hostname
It looks like you misspelled postgres as potgres.

Failed to establish initial TCP/IP connection (Chilkat-Python)

I'm trying to send a file from raspberry pi to my Windows pc using python-chilkat module. However it is returning this kind of error:
ChilkatLog: Connect_Ssh: DllDate: Dec 21 2018 ChilkatVersion: 9.5.0.76
UnlockPrefix: 30-day trial Architecture: Little Endian; 32-bit
Language: armhf linux Python 3.* VerboseLogging: 0 connectInner:
hostname: 192.168.1.4 port: 22 sshConnect:
connectSocket:
connect_ipv6_or_ipv4:
getsockopt indicates an error.
socketErrno: 111
socketError: Connection refused
--connect_ipv6_or_ipv4
connect_ipv6_or_ipv4:
getsockopt indicates an error.
socketErrno: 111
socketError: Connection refused
--connect_ipv6_or_ipv4
connect_ipv6_or_ipv4:
getsockopt indicates an error.
socketErrno: 111
socketError: Connection refused
--connect_ipv6_or_ipv4
connect_ipv6_or_ipv4:
getsockopt indicates an error.
socketErrno: 111
socketError: Connection refused
--connect_ipv6_or_ipv4
--connectSocket
Failed to establish initial TCP/IP connection
hostname: 192.168.1.4
port: 22 --sshConnect
--connectInner Failed.
--Connect_Ssh
--ChilkatLog
Can someone explain to me why Im getting these error?
See this online example which experiments with different failure cases to see what errors are returned: https://www.example-code.com/chilkat2-python/socket_connect_fail.asp
In some of the test cases, you'll see "connection rejected" which is the same as "connection refused". In other cases you'll get a timeout. The cases that result in "connection rejected" are the most likely causes for the failure.
PS> I understand that the example I'm pointing to is for a simple TCP socket connection, but SSH begins with a simple TCP connection, and that is what is failing.

Installing sdkman on cygwin

I'm having trouble installing sdkman on cygwin. The instructions say to run the command:
curl "https://get.sdkman.io" | bash
When I run this command in cygwin I get this:
$ curl "https://get.sdkman.io" | bash
% Total % Received % Xferd Average Speed Time Time Time
Dload Upload Total Spent Left
0 0 0 0 0 0 0 0 --:--:-- 0:03:56 --:--:--
Nothing is downloaded and the connection eventually times out.
Any ideas why this is happening? Maybe related to the firewall or something not being properly installed? Any solution ideas would be helpful, thanks.
UPDATE:
I tried wget as well and got this:
$ wget https://get.sdkman.io
--2018-02-09 13:29:47-- https://get.sdkman.io/
Resolving get.sdkman.io (get.sdkman.io)... 162.243.83.58
Connecting to get.sdkman.io (get.sdkman.io)|162.243.83.58|:443... failed:
Connection timed out.
Retrying.
--2018-02-09 13:30:09-- (try: 2) https://get.sdkman.io/
Connecting to get.sdkman.io (get.sdkman.io)|162.243.83.58|:443... failed:
Connection timed out.
Retrying.
--2018-02-09 13:30:32-- (try: 3) https://get.sdkman.io/
Connecting to get.sdkman.io (get.sdkman.io)|162.243.83.58|:443... failed:
Connection timed out.
Retrying.
--2018-02-09 13:30:56-- (try: 4) https://get.sdkman.io/
Connecting to get.sdkman.io (get.sdkman.io)|162.243.83.58|:443...
Thank you, it ended up being a network issue. My companies firewall is very selective and I was able to circumvent it with a wireless modem stick.

Azure Hybrid Connection trouble-shooting

In both Azure and the Hybrid Connection Manager I have a status of 'Connected' but when I try tcpping to it fails.
Apart from tccping, is there any other trouble shooting I can do?
The HCM endpoint is DESDESKTOP-6E0E4QK:5162. Here are my tccping results
tcpping DESDESKTOP-6E0E4QK:5162
D:\home\site\wwwroot
Connection attempt failed: No such host is known
Connection attempt failed: No such host is known
Connection attempt failed: No such host is known
Connection attempt failed: No such host is known
Complete: 0/4 successfull attempts (0%). Average success time: 0ms
Internal IP that resolves to DESDESKTOP-6E0E4QK
tcpping 192.168.1.158:5162
D:\home\site\wwwroot
Connection attempt failed: An attempt was made to access a socket in a way forbidden by its access permissions 192.168.1.158:5162
Connection attempt failed: An attempt was made to access a socket in a way forbidden by its access permissions 192.168.1.158:5162
Connection attempt failed: An attempt was made to access a socket in a way forbidden by its access permissions 192.168.1.158:5162
Connection attempt failed: An attempt was made to access a socket in a way forbidden by its access permissions 192.168.1.158:5162
Complete: 0/4 successfull attempts (0%). Average success time: 0ms
External IP
tcpping 47.198.9.249:5162
D:\home\site\wwwroot
Connection attempt failed: Connection timed out.
Connection attempt failed: Connection timed out.
Connection attempt failed: Connection timed out.
Connection attempt failed: Connection timed out.
Complete: 0/4 successfull attempts (0%). Average success time: 0ms

Resources