google-api-python-client: `socket.timeout: timed out` when using full IPv6 stack.
Environment details
- OS:
macOS 10.14.5 (18F132) Mojave
- Python version:
3.7.3
- pip version:
19.1.1
google-api-python-client
version:1.7.9
Steps to reproduce
Pre-steps:
- Have a full IPv6 stack with an IPv6 address. In my case, I have the following from Spectrum, through a Linksys WRT3200ACM router.
inet6 fe80::4ab:197d:b439:8d97%en0 prefixlen 64 secured scopeid 0x9
inet6 2604:6000:1013:a0eb:cca:87bb:d7ed:91b6 prefixlen 64 autoconf secured
inet6 2604:6000:1013:a0eb:91e1:1128:7728:8e1 prefixlen 64 autoconf temporary
Error:
- Follow the steps for the Python Quickstart (https://developers.google.com/docs/api/quickstart/python)
- run
python quickstart.py
- python exits with
socket.timeout: timed out
error
If I open System Preferences > Network > Wi-FI > Advanced > TCP/IP
and change the IPv6 configuration from Automatically
to Link-local only
, the quickstart.py properly runs.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 3
- Comments: 35 (15 by maintainers)
Commits related to this issue
- debugging https://github.com/googleapis/google-api-python-client/issues/709 — committed to SurferJeffAtGoogle/scratch by SurferJeffAtGoogle 4 years ago
- Add timeouts If we don't specify a timeout, requests could hang for minutes or more. E.g. on systems that use IPv6 sometimes requests to Google remain stuck for minutes because their firewalls (for ... — committed to glumia/aws-google-auth by deleted user 3 years ago
- Add timeouts If we don't specify a timeout, requests could hang for minutes or more. E.g. on systems that use IPv6 sometimes requests to Google remain stuck for minutes because their firewalls (for ... — committed to glumia/aws-google-auth by deleted user 3 years ago
@vladignatyev - I had this error and was able to get around it by updating /etc/gai.conf to prefer IPV4 over IPV6 (uncomment the line
precedence ::ffff:0:0/96 100
).Had the same issue. I can see from a nmap that TCP ports 80 and 443 are not open on the IPv6 addresses for www.googleapis.com but they are open for IPv4 addresses:
I used the quick hack from here in my code to force the underlying socket to connect over IPv4: https://stackoverflow.com/a/50044152
It looks like a Google firewall issue
Socket problem is still here, in 2020.
Environment details
python:3.8.0-alpine
)Container runs on AWS EC2 instance.
I’m experiencing this right now, the whole weekend, a code that was previoudly fine now i can’t get pass authentication:
…/python3.8/site-packages/httplib2/init.py, line 1324, in connect sock.connect((self.host.self.port__ socket.timetou: time out
Any advices how to solve this ?
Also getting this same issue… working code using the Sheets API just stopped. and now getting the socket timeout error every single time. I’ve tried oauth and API key and am seeing identical results.
I tried the workaround linked above and was unable to make progress.
Even in places where the code make it through (like authorizing the credentials), it take 2-5 minutes where before it was happening almost instantly (note: before meaning ‘when the code worked’ not ‘before the workaround’).
have been experiencing this intermittently as well while using the gmail client, will try catching and retrying for now to see if that gets through it
@nulld mentioned a workaround in #563 where he had to move the
socket.setdefaulttimeout()
function beforeimport googleapiclient
. If it solves the problem, then credit goes to @nulld ! Either way, we can use this data point to better understand whether there are multiple issues going on. Please can someone who is experiencing the issue try the workaround and report back?