icloud-photos-downloader / icloud_photos_downloader

A command-line tool to download photos from iCloud
MIT License
6.57k stars 534 forks source link

Max retries exceeded with url #643

Closed sonicflame17 closed 9 months ago

sonicflame17 commented 1 year ago

I don't think this is a bug- I think it's specific to my configuration, but something is unhappy, and I've been trying to fix it myself off and on for several months and am finally waving the white flag.

A bit of background- I'm on a Mac. I upgraded my Python install to 3.10 to install another package that required it, but after reading here in another issue report that it could be a problem I downgraded to 3.8.

I have the following configuration installed:

MacPro:clouddownload melissa$ python3.8 --version Python 3.8.17 MacPro:clouddownload melissa$ pip3.8 --version pip 23.1.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8) MacPro:clouddownload melissa$ icloudpd --version icloudpd, version 1.13.4

Running command: icloudpd --directory . --until-found 1000

And I get this error over and over after providing my login:

Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn conn = connection.create_connection( File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 72, in create_connection for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): File "/usr/local/Cellar/python@3.8/3.8.17/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socket.py", line 918, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno 8] nodename nor servname provided, or not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 714, in urlopen httplib_response = self._make_request( File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 403, in _make_request self._validate_conn(conn) File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1053, in _validate_conn conn.connect() File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 363, in connect self.sock = conn = self._new_conn() File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 186, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x104401f40>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 486, in send resp = conn.urlopen( File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 798, in urlopen retries = retries.increment( File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 592, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='setup.icloud.com', port=443): Max retries exceeded with url: /setup/ws/1/login?clientBuildNumber=17DHotfix5&clientMasteringNumber=17DHotfix5&ckjsBuildVersion=17DProjectDev77&ckjsVersion=2.0.5&clientId=0C0442BE-0D97-11EE-9016-503EAA89BE5B (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x104401f40>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/bin/icloudpd", line 8, in sys.exit(main()) File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1130, in call return self.main(args, kwargs) File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/local/lib/python3.8/site-packages/click/core.py", line 760, in invoke return __callback(args, kwargs) File "/usr/local/lib/python3.8/site-packages/icloudpd/base.py", line 283, in main core( File "/usr/local/lib/python3.8/site-packages/icloudpd/base.py", line 570, in core icloud = authenticator(domain)( File "/usr/local/lib/python3.8/site-packages/icloudpd/authentication.py", line 32, in authenticate_ icloud = pyicloud_ipd.PyiCloudService( File "/usr/local/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 204, in init self.authenticate() File "/usr/local/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 220, in authenticate req = self.session.post( File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 637, in post return self.request("POST", url, data=data, json=json, kwargs) File "/usr/local/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 71, in request response = super(PyiCloudSession, self).request(*args, kwargs) File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 519, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='setup.icloud.com', port=443): Max retries exceeded with url: /setup/ws/1/login?clientBuildNumber=17DHotfix5&clientMasteringNumber=17DHotfix5&ckjsBuildVersion=17DProjectDev77&ckjsVersion=2.0.5&clientId=0C0442BE-0D97-11EE-9016-503EAA89BE5B (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x104401f40>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))

Does anyone have any ideas about how to fix this?

mareczek82 commented 1 year ago

today i have this _Traceback (most recent call last): File "urllib3/connection.py", line 174, in _new_conn File "urllib3/util/connection.py", line 72, in create_connection File "socket.py", line 962, in getaddrinfo socket.gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "urllib3/connectionpool.py", line 703, in urlopen File "urllib3/connectionpool.py", line 386, in _make_request File "urllib3/connectionpool.py", line 1042, in _validate_conn File "urllib3/connection.py", line 363, in connect File "urllib3/connection.py", line 186, in _new_conn urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f26f5bf8e50>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "requests/adapters.py", line 489, in send File "urllib3/connectionpool.py", line 787, in urlopen File "urllib3/util/retry.py", line 592, in increment urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='p66-ckdatabasews.icloud.com', port=443): Max retries exceeded with url: /database/1/com.apple.photos.cloud/production/private/records/query?clientBuildNumber=17DHotfix5&clientMasteringNumber=17DHotfix5&ckjsBuildVersion=17DProjectDev77&ckjsVersion=2.0.5&clientId=1FAC6546-0ECB-11EE-AD07-77D5B38F59E8&dsid=1331465246&remapEnums=True&getCurrentSyncToken=True (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f26f5bf8e50>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "icloudpd.py", line 5, in File "click/core.py", line 1130, in call File "click/core.py", line 1055, in main File "click/core.py", line 1404, in invoke File "click/core.py", line 760, in invoke File "icloudpd/base.py", line 283, in main File "icloudpd/base.py", line 601, in core File "pyicloud_ipd/base.py", line 346, in photos File "pyicloud_ipd/services/photos.py", line 157, in init File "requests/sessions.py", line 635, in post File "pyicloudipd/base.py", line 71, in request File "requests/sessions.py", line 587, in request File "requests/sessions.py", line 701, in send File "requests/adapters.py", line 565, in send requests.exceptions.ConnectionError: HTTPSConnectionPool(host='p66-ckdatabasews.icloud.com', port=443): Max retries exceeded with url: /database/1/com.apple.photos.cloud/production/private/records/query?clientBuildNumber=17DHotfix5&clientMasteringNumber=17DHotfix5&ckjsBuildVersion=17DProjectDev77&ckjsVersion=2.0.5&clientId=1FAC6546-0ECB-11EE-AD07-77D5B38F59E8&dsid=1331465246&remapEnums=True&getCurrentSyncToken=True (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f26f5bf8e50>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')) [1558040] Failed to execute script 'icloudpd' due to unhandled exception!

I'm not programist, but it looks simmilar

AndreyNikiforov commented 1 year ago

The error suggests that connection from icloudpd to iCloud service cannot be established.

  1. What country are you running icloudpd in? There was a big issue some time ago when iCloud.com stopped working in mainland China -- trying to eliminate similar situation (the error was different though).

  2. How are you running icloudpd and what versions? Checking if some dependency started to fail. Although would be very strange to see failure with connectivity errors, worth checking IMO. One of the best ways to test is to use latest binaries from releases or docker. See nuances for mac

mareczek82 commented 1 year ago

I live in Poland. I had this problem for two days - now it works fine. running icloudpd-1.13.0-linux-amd64 on Ubuntu 22 LTS

Yesterday icloudpd asked for new authentuication code - i'm not sure was it connected with issue before or just accidental coincidence.

sonicflame17 commented 1 year ago

The error suggests that connection from icloudpd to iCloud service cannot be established.

  1. What country are you running icloudpd in? There was a big issue some time ago when iCloud.com stopped working in mainland China -- trying to eliminate similar situation (the error was different though).
  2. How are you running icloudpd and what versions? Checking if some dependency started to fail. Although would be very strange to see failure with connectivity errors, worth checking IMO. One of the best ways to test is to use latest binaries from releases or docker. See nuances for mac

I am in the United States.

I run icloudpd from Terminal (also installed via Terminal using pip) and am getting the same error on 2 different Macs.

The setup for the first Mac is:

Python 3.8.17 pip 23.1.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8) icloudpd, version 1.13.4 MacOS Mojave (it's an old computer)

The second Mac is:

Python 3.10.10 pip 23.0 from /usr/local/lib/python3.10/site-packages/pip (python 3.10) icloudpd, version 1.13.4 MacOS Monterey

AndreyNikiforov commented 1 year ago

I run icloudpd from Terminal (also installed via Terminal using pip) and am getting the same error on 2 different Macs.

That is strange. Is Mac setup somehow different from vanilla? E.g. VPN? Can you open iCloud.com from the browser and see photos on your account?

Can you try downloading binary from releases and try it, please? I want to eliminate any possibility of python dependencies. See nuances for mac

sonicflame17 commented 1 year ago

I run icloudpd from Terminal (also installed via Terminal using pip) and am getting the same error on 2 different Macs.

That is strange. Is Mac setup somehow different from vanilla? E.g. VPN? Can you open iCloud.com from the browser and see photos on your account?

Can you try downloading binary from releases and try it, please? I want to eliminate any possibility of python dependencies. See nuances for mac

It's a completely vanilla install on both computers- no VPN or other complications. After I posted yesterday, I downloaded Docker and installed in a container there, then ran and had the same error. I can go to iCloud.com and see my photos from the browser on both computers.

AndreyNikiforov commented 1 year ago

It's a completely vanilla install on both computers- no VPN or other complications. After I posted yesterday, I downloaded Docker and installed in a container there, then ran and had the same error. I can go to iCloud.com and see my photos from the browser on both computers.

Was icloudpd ever working for you?

Here is my validation with docker (changed email and auth code; ran in Windows, but that should not matter):

docker run --rm -it icloudpd/icloudpd:1.13.4 icloudpd --directory . --only-print-filenames --recent 1
iCloud username/email: my@email.address
iCloud Password:
  0: SMS to ********81
  1: Enter two-factor authentication code
Please choose an option: [0]: 1
Please enter two-factor authentication code: 123456
2023/06/28/964416c0-c744-44e7-accb-627089939875.jpg

Note that two-factor auth code I am receiving on my Apple devices.

Does your session start similar? I am trying to check if some combination of parameters/entries you use lead to code path that is executed with missing/wrong address.

sonicflame17 commented 1 year ago

Was icloudpd ever working for you?

Yes. I used it for over a year before this started. I assumed I needed to update something on my install when it first started happening, but when that failed I tried a completely fresh install on a different computer and am getting the same error.

Note that two-factor auth code I am receiving on my Apple devices.

Does your session start similar? I am trying to check if some combination of parameters/entries you use lead to code path that is executed with missing/wrong address.

I don't even get to the 2 factor authentication now. It fails as soon as I press return after entering my Apple ID. I previously had passed 2FA on this computer and stored a token for it, so I haven't had to go through that since my first run.

iCloud username/email: *******@yahoo.com
2023-07-06 15:55:48 DEBUG    Authenticating...
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 72, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/Cellar/python@3.8/3.8.17/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

etc, etc.
sonicflame17 commented 1 year ago

I wanted to come back and post what is a possible fix just in case anyone else has this issue. I changed the default DNS server in my router from my ISP's default to Google's DNS (8.8.8.8), and suddenly icloudpd is working again. I don't know if it's just a coincidence, but it's the only change I made and it started working again immediately afterward.