-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Requests from urllib and requests library have long delays #95838
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
Comments
Do network requests using other mechanism work? (e.g., curl, a browser, other languages' web stacks) This sounds like a problem with your network stack. There's also some chance it's something IPv6-specific; you can try to figure out whether it's trying to use an IPv6 or IPv4 address. |
Ahh thank you, I forgot to add that info. Yes, curl works.
As for the IPv4/IPv6, that's an interesting thought. I'll try that out and get back to this forum. |
@JelleZijlstra, quick testing is concluding that this is indeed something to do with IPv6 or possibly with running in dual stack. The below results are running with only an IPv4 address.
I will continue working on scoping this to see if this is a problem with Python or networking equipment. Any guidance or reading material I could use to debug this further on Python side? I hit a wall once I found out it was stuck at sock.connect. I generally don't go this low. |
I don't have great ideas, but the past experience that led me to mention IPv6 is that I've seen something similar inside AWS machines: IPv4 is fine but IPv6 requests hang. You say you're on a Mac, so you're probably not in AWS, but maybe your network stack is having something similar happen. A useful datapoint could be whether IPv6 connections also hang when you use other tools, such as curl. |
#88810 might be relevant here, that proposes to add an implementation of the Hapyy Eyeballs algorithm in non-asyncio socket creation to improve performance in dual-stack environments. |
After additional testing, I have been able to conclude that this is something specific with my AnyConnect VPN back to HQ. I'll work with IT to see what policy they have which could be blackholing IPv6 traffic. When I'm not on VPN, everything works fine. I'll close this out, but to @ronaldoussoren's point, implementing the Happy Eyeballs algorithm would mitigate against this. If that can't be done, having a way to alert the user of what's happening would be good. Especially since duel stack is only going to become more popular in the near future. |
Bug report
On multiple MacOS systems running 12.4, the HTTP requests fail to establish on the initial connection attempt, blocking on sock.connect.
Your environment
Data
Requests made to a site will consistently take over one minute to complete, as shown below with a few examples. This doesn't matter if the requests or urllib library is used.
But then, if I add a timeout, it's timeout+request time.
If I get a traceback during one of these long deadlocks I have the following trace.
Last bits of data
This has been a problem on two of my work machines -- freshly reprovisioned. This is not a problem on my Windows Desktop, or Ubuntu server. Lastly, I had two colleagues both running MacOS and they do not have this problem. This is a problem with and without the IDE.
I'm unsure if this is a problem with a package or something else I have installed.
The text was updated successfully, but these errors were encountered: