Any way to set connect-timeout per-IP, not global?

ValdikSS via curl-users <[email protected]> Fri, 11 Oct 2024 18:47:09 +0300
Newsgroups gmane.comp.web.curl.general
Message-ID <[email protected]>
Hello list,

Currently curl, when used with --connect-timeout option, uses it as a 
global timeout for the whole connection set, decreasing the timeout for 
each IP address in half every connection attempt.

If several IP addresses from the top of DNS resolution are not working, 
the others (potentially working ones) just won't get enough timeout to 
establish the connection.

Take a look:

$ dig +short proxy-ssl.antizapret.prostovpn.org | xargs echo
51.77.61.44 51.38.124.100 51.89.143.227 46.105.53.114 51.77.61.42 
141.95.37.139 46.105.53.157 46.105.53.63 51.77.61.38 51.15.64.69 
46.105.53.150

$ curl --connect-timeout 5 https://proxy-ssl.antizapret.prostovpn.org 
--interface lo -v
* processing: https://proxy-ssl.antizapret.prostovpn.org
*   Trying 51.77.61.42:443...
* ipv4 connect timeout after 2499ms, move on!
*   Trying 51.77.61.44:443...
* ipv4 connect timeout after 1250ms, move on!
*   Trying 46.105.53.63:443...
* ipv4 connect timeout after 624ms, move on!
*   Trying 51.15.64.69:443...
* ipv4 connect timeout after 312ms, move on!
*   Trying 51.89.143.227:443...
* ipv4 connect timeout after 155ms, move on!
*   Trying 46.105.53.150:443...
* ipv4 connect timeout after 77ms, move on!
*   Trying 46.105.53.114:443...
* ipv4 connect timeout after 38ms, move on!
*   Trying 46.105.53.157:443...
* ipv4 connect timeout after 19ms, move on!
*   Trying 141.95.37.139:443...
* ipv4 connect timeout after 9ms, move on!
*   Trying 51.38.124.100:443...
* ipv4 connect timeout after 5ms, move on!
*   Trying 51.77.61.38:443...
* ipv4 connect timeout after 4ms, move on!
* Failed to connect to proxy-ssl.antizapret.prostovpn.org port 443 after 
5000 ms: Timeout was reached
* Closing connection
curl: (28) Failed to connect to proxy-ssl.antizapret.prostovpn.org port 
443 after 5000 ms: Timeout was reached



This applies to both curl CLI and libcurl, --max-time / CURLOPT_TIMEOUT 
does not change the behavior of connection timeout.

Is there any way to change this behavior, to make connect-timeout to 
apply for each IP address individually?

Thanks.

-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
OpenPGP_signature.asc (application/pgp-signature, 840 B)
-----BEGIN PGP SIGNATURE-----

wsF5BAABCAAjFiEEMiogvXcpmS32v71gXNcgLu+I93IFAmcJSH0FAwAAAAAACgkQXNcgLu+I93IS
BhAAmaFElKB2z9aqGYeEZ9zVtvqLaR69pkOyL0BrPo2sn/000294uEIOmxyrhgHxa+7IPg0c4Cp+
sBTL5msjQk0BbN2XM5/+GQStFoQfFDsMFIKzbkr9+rNnKy/O4qUf1htwhV3HRt3gzF55sa9Xixo3
Nu38bAM2XuzC/eP34B4ZQbrZf6M8QUGYNp59NedKx9EegAKg8BZQifJslrIHxjYEiqeRAWTpKM3W
fue0Uee+ctfFr4uY0PFJrug4U/jlmZlZHThZegrIFnWAypbcFQ/11jsKwHB9KEsyfWV9cbMb2UkZ
DT89xTEeOmCPLiWV/zKZXHXYGgisklbL+sp7+ywz/6hXkJO6mGPOr0JKHvITWlSOlrm19djgdVcm
qbXtnnSKwDPHn74qZta55RRGNfh8LVPL8yhAOHWNElvnCusMEOYJSPFw1r3PmEfJiGsY0FLeUBIO
8QUoKIsUhpWi7rf74fHu/2JXHL+wETGehd4yr1gYntzmagF9KCgUIxGywdp6k5BlP1F5sYWiQqae
x504vXZrYfbLWSKFzbKQw6Lr0FIw9vWCvFpVLEojTEY3uj+X2/QN7K9dVfxt+KHTxxdjy9zKaYLz
evuagBaZR+6q7r+N3vHiCZqyxbAWCHWUgCxu/AWd/HnfCxF7FhC4RpDyV8IAyiRiQQcH6p7vwDP4
v+A=
=It3n
-----END PGP SIGNATURE-----