-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
curl: (45) bind failed with errno 22: Invalid argument #3993
Comments
Related issue: #686 |
So whenever I specify And the related issue #686 has been reported 3 years ago, so I can conclude it won't be fixed. Correct? |
No, I don't think that's even close. The problem with the current local bind code is that it works rather independently of the remote end which creates this weirdo problems with v4 vs v6 or problems with different v6 scopes.
It means that the issue has been reported and we know about it but nobody has yet fixed it. It is a bug and we'd like to have it fixed. |
Will the code suggested here https://stackoverflow.com/questions/3736335/tell-whether-a-text-string-is-an-ipv6-address-or-ipv4-address-using-standard-c-s/3736377#3736377 help to solve the issue? |
I don't think so. I believe this problem you see happens because curl first resolves the host name and tries to connect to it (over both IPv4 and IPv6), and also tries to bind that socket to the address you've asked - without properly caring for IP version mixes. A proper fix would probably be something like: if |
And the code snippet shows how to detect which IP is specified in Actually found the issue in Zabbix first, they use cURL library, and connections to monitored hosts over HTTP/HTTPs fails in mentioned here cases. Reported the issue to https://support.zabbix.com/browse/ZBX-16082 Kindly advise. Regards, |
Reported-by: Alex Grebenschikov Fixes #3993
Not necessary, since all the info is already there. We just need to fix the detection logic. Something like I've tried now in #4002. Can you see if this works or if you can make it work? |
Thanks. The suggested patch works. |
Excellent, thanks for confirming! |
Hello,
Error
An error
curl: (45) bind failed with errno 22: Invalid argument
occurs whenever we specify IPv4 from local interface as a source address trying to connect to a site which have both IPv4 and IPv6.Steps to reproduce
Pick up a domain which resolves both to IPv4 and IPv6:
The request:
can be fixed with
-4
flag:OS
Tested with CentOS 7:
curl-7.29.0-51.el7.x86_64
curl 7.65.1-DEV (x86_64-unknown-linux-gnu) libcurl/7.65.1-DEV OpenSSL/1.0.2k-fips zlib/1.2.7
Results are the same.
Expected behavior:
Whenever a source IPv4 is specified cURL should auto add -4 flag, i.e.:
The same with IPv6, whenever a source IPv6 is specified cURL should auto add -6 flag, i.e.
Regards,
Alex.
The text was updated successfully, but these errors were encountered: