mrworf / photoframe

Software to pull random photos from Google Photos and show them, like a photo frame
GNU General Public License v3.0
215 stars 38 forks source link

Photoframe freezing when loss of network connection? #186

Open ccshc opened 3 years ago

ccshc commented 3 years ago

Hi,

I think my network connection is dropping occasionally, which seems to cause the PhotoFrame to just keep showing the same picture.

The summary is ConnectionError: HTTPSConnectionPool fails 5 times, which eventually triggers an error when it trys to display a photo which it hasn't got.

I can solve this by rebooting.

A possible solution would be that if the network fails to connect, have a longer delay (eg a minute) between retries rather than instantaneously trying again.

The full log is below:

Mar 10 14:04:17 photoframe photoframe[396]: 2021-03-10 14:04:17,843 - WARNING - jpegexiforient is missing, no auto rotate available. Did you forget to run "apt install libjpeg-turbo-progs" ?
Mar 10 14:05:09 photoframe photoframe[396]: 2021-03-10 14:05:09,339 - ERROR - Issues downloading
Mar 10 14:05:09 photoframe photoframe[396]: Traceback (most recent call last):
Mar 10 14:05:09 photoframe photoframe[396]:   File "/root/photoframe/modules/oauth.py", line 72, in request
Mar 10 14:05:09 photoframe photoframe[396]:     result = auth.get(uri, stream=stream, params=params, timeout=180)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 501, in get
Mar 10 14:05:09 photoframe photoframe[396]:     return self.request('GET', url, **kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests_oauthlib/oauth2_session.py", line 358, in request
Mar 10 14:05:09 photoframe photoframe[396]:     headers=headers, data=data, **kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 488, in request
Mar 10 14:05:09 photoframe photoframe[396]:     resp = self.send(prep, **send_kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 609, in send
Mar 10 14:05:09 photoframe photoframe[396]:     r = adapter.send(request, **kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 487, in send
Mar 10 14:05:09 photoframe photoframe[396]:     raise ConnectionError(e, request=request)
Mar 10 14:05:09 photoframe photoframe[396]: ConnectionError: HTTPSConnectionPool(host='photoslibrary.googleapis.com', port=443): Max retries exceeded with url: /v1/mediaItems/AHQdp5MMuc5aQ4ct9ipZvvVaJC9n_PBjMV9KTtW7-ZHG_mHBwGGb79p1gb-fkO76Gz6lWHZbRBiIb-kTLxHGclAtTKGG8G3Fxg (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
Mar 10 14:05:09 photoframe photoframe[396]: 2021-03-10 14:05:09,370 - WARNING - Retrying again, attempt #1
Mar 10 14:05:09 photoframe photoframe[396]: 2021-03-10 14:05:09,466 - ERROR - Issues downloading
Mar 10 14:05:09 photoframe photoframe[396]: Traceback (most recent call last):
Mar 10 14:05:09 photoframe photoframe[396]:   File "/root/photoframe/modules/oauth.py", line 72, in request
Mar 10 14:05:09 photoframe photoframe[396]:     result = auth.get(uri, stream=stream, params=params, timeout=180)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 501, in get
Mar 10 14:05:09 photoframe photoframe[396]:     return self.request('GET', url, **kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests_oauthlib/oauth2_session.py", line 358, in request
Mar 10 14:05:09 photoframe photoframe[396]:     headers=headers, data=data, **kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 488, in request
Mar 10 14:05:09 photoframe photoframe[396]:     resp = self.send(prep, **send_kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 609, in send
Mar 10 14:05:09 photoframe photoframe[396]:     r = adapter.send(request, **kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 487, in send
Mar 10 14:05:09 photoframe photoframe[396]:     raise ConnectionError(e, request=request)
Mar 10 14:05:09 photoframe photoframe[396]: ConnectionError: HTTPSConnectionPool(host='photoslibrary.googleapis.com', port=443): Max retries exceeded with url: /v1/mediaItems/AHQdp5MMuc5aQ4ct9ipZvvVaJC9n_PBjMV9KTtW7-ZHG_mHBwGGb79p1gb-fkO76Gz6lWHZbRBiIb-kTLxHGclAtTKGG8G3Fxg (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
Mar 10 14:05:09 photoframe photoframe[396]: 2021-03-10 14:05:09,484 - WARNING - Retrying again, attempt #2
Mar 10 14:05:09 photoframe photoframe[396]: 2021-03-10 14:05:09,566 - ERROR - Issues downloading
Mar 10 14:05:09 photoframe photoframe[396]: Traceback (most recent call last):
Mar 10 14:05:09 photoframe photoframe[396]:   File "/root/photoframe/modules/oauth.py", line 72, in request
Mar 10 14:05:09 photoframe photoframe[396]:     result = auth.get(uri, stream=stream, params=params, timeout=180)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 501, in get
Mar 10 14:05:09 photoframe photoframe[396]:     return self.request('GET', url, **kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests_oauthlib/oauth2_session.py", line 358, in request
Mar 10 14:05:09 photoframe photoframe[396]:     headers=headers, data=data, **kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 488, in request
Mar 10 14:05:09 photoframe photoframe[396]:     resp = self.send(prep, **send_kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 609, in send
Mar 10 14:05:09 photoframe photoframe[396]:     r = adapter.send(request, **kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 487, in send
Mar 10 14:05:09 photoframe photoframe[396]:     raise ConnectionError(e, request=request)
Mar 10 14:05:09 photoframe photoframe[396]: ConnectionError: HTTPSConnectionPool(host='photoslibrary.googleapis.com', port=443): Max retries exceeded with url: /v1/mediaItems/AHQdp5MMuc5aQ4ct9ipZvvVaJC9n_PBjMV9KTtW7-ZHG_mHBwGGb79p1gb-fkO76Gz6lWHZbRBiIb-kTLxHGclAtTKGG8G3Fxg (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
Mar 10 14:05:09 photoframe photoframe[396]: 2021-03-10 14:05:09,580 - WARNING - Retrying again, attempt #3
Mar 10 14:05:09 photoframe photoframe[396]: 2021-03-10 14:05:09,660 - ERROR - Issues downloading
Mar 10 14:05:09 photoframe photoframe[396]: Traceback (most recent call last):
Mar 10 14:05:09 photoframe photoframe[396]:   File "/root/photoframe/modules/oauth.py", line 72, in request
Mar 10 14:05:09 photoframe photoframe[396]:     result = auth.get(uri, stream=stream, params=params, timeout=180)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 501, in get
Mar 10 14:05:09 photoframe photoframe[396]:     return self.request('GET', url, **kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests_oauthlib/oauth2_session.py", line 358, in request
Mar 10 14:05:09 photoframe photoframe[396]:     headers=headers, data=data, **kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 488, in request
Mar 10 14:05:09 photoframe photoframe[396]:     resp = self.send(prep, **send_kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 609, in send
Mar 10 14:05:09 photoframe photoframe[396]:     r = adapter.send(request, **kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 487, in send
Mar 10 14:05:09 photoframe photoframe[396]:     raise ConnectionError(e, request=request)
Mar 10 14:05:09 photoframe photoframe[396]: ConnectionError: HTTPSConnectionPool(host='photoslibrary.googleapis.com', port=443): Max retries exceeded with url: /v1/mediaItems/AHQdp5MMuc5aQ4ct9ipZvvVaJC9n_PBjMV9KTtW7-ZHG_mHBwGGb79p1gb-fkO76Gz6lWHZbRBiIb-kTLxHGclAtTKGG8G3Fxg (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
Mar 10 14:05:09 photoframe photoframe[396]: 2021-03-10 14:05:09,664 - WARNING - Retrying again, attempt #4
Mar 10 14:05:09 photoframe photoframe[396]: 2021-03-10 14:05:09,751 - ERROR - Issues downloading
Mar 10 14:05:09 photoframe photoframe[396]: Traceback (most recent call last):
Mar 10 14:05:09 photoframe photoframe[396]:   File "/root/photoframe/modules/oauth.py", line 72, in request
Mar 10 14:05:09 photoframe photoframe[396]:     result = auth.get(uri, stream=stream, params=params, timeout=180)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 501, in get
Mar 10 14:05:09 photoframe photoframe[396]:     return self.request('GET', url, **kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests_oauthlib/oauth2_session.py", line 358, in request
Mar 10 14:05:09 photoframe photoframe[396]:     headers=headers, data=data, **kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 488, in request
Mar 10 14:05:09 photoframe photoframe[396]:     resp = self.send(prep, **send_kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 609, in send
Mar 10 14:05:09 photoframe photoframe[396]:     r = adapter.send(request, **kwargs)
Mar 10 14:05:09 photoframe photoframe[396]:   File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 487, in send
Mar 10 14:05:09 photoframe photoframe[396]:     raise ConnectionError(e, request=request)
Mar 10 14:05:09 photoframe photoframe[396]: ConnectionError: HTTPSConnectionPool(host='photoslibrary.googleapis.com', port=443): Max retries exceeded with url: /v1/mediaItems/AHQdp5MMuc5aQ4ct9ipZvvVaJC9n_PBjMV9KTtW7-ZHG_mHBwGGb79p1gb-fkO76Gz6lWHZbRBiIb-kTLxHGclAtTKGG8G3Fxg (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
Mar 10 14:05:09 photoframe photoframe[396]: 2021-03-10 14:05:09,755 - WARNING - Retrying again, attempt #5
Mar 10 14:05:09 photoframe photoframe[396]: 2021-03-10 14:05:09,757 - ERROR - Failed to download due to network issues
Mar 10 14:05:09 photoframe photoframe[396]: 2021-03-10 14:05:09,769 - WARNING - jpegexiforient is missing, no auto rotate available. Did you forget to run "apt install libjpeg-turbo-progs" ?
Mar 10 14:05:09 photoframe photoframe[396]: 2021-03-10 14:05:09,771 - WARNING - File /tmp/framed_cb306b23-6a7f-456d-9e6d-8118f09b5c9f does not exist, so cannot get dimensions
Mar 10 14:05:09 photoframe photoframe[396]: 2021-03-10 14:05:09,776 - WARNING - Cannot frame /tmp/framed_cb306b23-6a7f-456d-9e6d-8118f09b5c9f since we cannot determine image dimensions
Mar 10 14:05:24 photoframe photoframe[396]: Exception in thread Thread-6:
Mar 10 14:05:24 photoframe photoframe[396]: Traceback (most recent call last):
Mar 10 14:05:24 photoframe photoframe[396]:   File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
Mar 10 14:05:24 photoframe photoframe[396]:     self.run()
Mar 10 14:05:24 photoframe photoframe[396]:   File "/usr/lib/python2.7/threading.py", line 754, in run
Mar 10 14:05:24 photoframe photoframe[396]:     self.__target(*self.__args, **self.__kwargs)
Mar 10 14:05:24 photoframe photoframe[396]:   File "/root/photoframe/modules/slideshow.py", line 328, in presentation
Mar 10 14:05:24 photoframe photoframe[396]:     self.showPreloadedImage(result)
Mar 10 14:05:24 photoframe photoframe[396]:   File "/root/photoframe/modules/slideshow.py", line 261, in showPreloadedImage
Mar 10 14:05:24 photoframe photoframe[396]:     logging.warning("Trying to show image '%s', but file does not exist!" % filename)
Mar 10 14:05:24 photoframe photoframe[396]: NameError: global name 'filename' is not defined
mrworf commented 3 years ago

Actually, there's backoff logic:

            time.sleep(tries / 10) # Back off 10, 20, ... depending on tries
            tries += 1
            logging.warning('Retrying again, attempt #%d', tries)

But I could have messed up and the division isn't turning into fractions, just zero which would explain what you're seeing :) Good catch

ccshc commented 3 years ago

I think that is just returning 0 delay! Maybe change it to time.sleep(tries * 10)?

mrworf commented 3 years ago

Yes, I think I confused it with minutes which is why it's a division. Should have been multiplied since it's seconds.

mrworf commented 2 years ago

Changes for the backoff timer as well as the use of a faulty variable name have been fixed on latest. Please let me know how it works @ccshc

dadr commented 2 years ago

I've been meaning to look back at this again. I still have seen this error with the revised code. If I read it correctly, the slideshow will stop if the Internet connection is down for ~2.5 min. That has happened to me several times, and the photoframe does not recover after the Internet comes back. I'd rather have it back off a bit more and then continue to test for connectivity periodically. Maybe every 5 min?

mrworf commented 2 years ago

I actually found the issue the other night, just need to test some more.