10000 Add ability to disable IPv4 · Issue #3553 · urllib3/urllib3 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add ability to disable IPv4 #3553

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

Open
robd003 opened this issue Jan 23, 2025 · 1 comment
Open

Add ability to disable IPv4 #3553

robd003 opened this issue Jan 23, 2025 · 1 comment

Comments

@robd003
Copy link
robd003 commented Jan 23, 2025

Context

In AWS EC2 users now have to pay for public IPv4 addresses. Lots of people are migrating to IPv6 hosts, but usually there will still be an IPv4 private network.

Unfortunately when a user tries to access a service like email.us-east-2.api.aws the DNS resolver will return both A and AAAA records. urllib3 will try to connect to the IPv4 address from the A record and your program will just hang until the timeout.

If I could just say "hey disable IPv4 since it isn't routable" for this request that would make life 10,000 times easier.

Alternatives

Really hacky method

import socket

def patched_getaddrinfo(*args, **kwargs):
    return socket.getaddrinfo(*args, family=socket.AF_INET6, **kwargs)

socket.getaddrinfo = patched_getaddrinfo

Duplicate

#2721

@SpecLad
Copy link
SpecLad commented Feb 6, 2025

It's odd that urllib3 would try the IPv4 address first, as it tries them in the order returned by getaddrinfo, and IPv6 normally takes priority in that. If you call socket.getaddrinfo('email.us-east-2.api.aws', 'https'), do IPv4 addresses come first in the results?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0