Plex-Auto-Languages icon indicating copy to clipboard operation
Plex-Auto-Languages copied to clipboard

Loss of websocket connection to Plex causes a permanent hang.

Open InsertDisc opened this issue 1 year ago • 5 comments

If Plex restarts and closes the websocket connection there is no attempt to reestablish the connection.

InsertDisc avatar Jul 03 '23 19:07 InsertDisc

When Plex closes the websocket connection you should have the following logs:

[WARNING] Lost connection to the Plex server
[INFO] Trying to restore the connection to the Plex server...

If not, do you have any logs that could indicate a failure ?

RemiRigal avatar Jul 05 '23 09:07 RemiRigal

I was getting [Warning] Plex closed the websocket connection.

I don't have exact logs to copy as I guess you lose them on a PAL restart.

After restarting Plex I would have to restart PAL as well to restore the connection.

Turns out the issue was a bit deeper. Running maintenance on Plex, having PAL listening and scanning with PMM was causing the server to crash.

I've separated the schedules a bit better to avoid the problem in the future. However, if somebody has a script to restore Plex after a crashed state, the issue with PAL reconnecting would probably still arise. Not something that should happen often, but it's still something that can.

Thank you for your great communication.

On Wed, Jul 5, 2023, 5:10 AM RemiRigal @.***> wrote:

When Plex closes the websocket connection you should have the following logs:

[WARNING] Lost connection to the Plex server [INFO] Trying to restore the connection to the Plex server...

If not, do you have any logs that could indicate a failure ?

— Reply to this email directly, view it on GitHub https://github.com/RemiRigal/Plex-Auto-Languages/issues/81#issuecomment-1621347305, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHSH2JWTVIFUDHWNOF6NN5TXOUVRDANCNFSM6AAAAAAZ42OZLI . You are receiving this because you authored the thread.Message ID: @.***>

InsertDisc avatar Jul 05 '23 12:07 InsertDisc

I do however get this randomly.

  • [2023-07-05 08:08:03,612] ERROR in app: Exception on / [GET]
  • 8:08:03 AM Traceback (most recent call last):
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 449, in _make_request
  • 8:08:03 AM six.raise_from(e, None)
  • 8:08:03 AM File "", line 3, in raise_from
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 444, in _make_request
  • 8:08:03 AM httplib_response = conn.getresponse()
  • 8:08:03 AM File "/usr/local/lib/python3.8/http/client.py", line 1348, in getresponse
  • 8:08:03 AM response.begin()
  • 8:08:03 AM File "/usr/local/lib/python3.8/http/client.py", line 316, in begin
  • 8:08:03 AM version, status, reason = self._read_status()
  • 8:08:03 AM File "/usr/local/lib/python3.8/http/client.py", line 277, in _read_status
  • 8:08:03 AM line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  • 8:08:03 AM File "/usr/local/lib/python3.8/socket.py", line 669, in readinto
  • 8:08:03 AM return self._sock.recv_into(b)
  • 8:08:03 AM socket.timeout: timed out
  • 8:08:03 AM
  • 8:08:03 AM During handling of the above exception, another exception occurred:
  • 8:08:03 AM
  • 8:08:03 AM Traceback (most recent call last):
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 489, in send
  • 8:08:03 AM resp = conn.urlopen(
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 787, in urlopen
  • 8:08:03 AM retries = retries.increment(
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 550, in increment
  • 8:08:03 AM raise six.reraise(type(error), error, _stacktrace)
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/urllib3/packages/six.py", line 770, in reraise
  • 8:08:03 AM raise value
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen
  • 8:08:03 AM httplib_response = self._make_request(
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 451, in _make_request
  • 8:08:03 AM self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 340, in _raise_timeout
  • 8:08:03 AM raise ReadTimeoutError(
  • 8:08:03 AM urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='192.168.1.7', port=32400): Read timed out. (read timeout=30)
  • 8:08:03 AM
  • 8:08:03 AM During handling of the above exception, another exception occurred:
  • 8:08:03 AM
  • 8:08:03 AM Traceback (most recent call last):
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2528, in wsgi_app
  • 8:08:03 AM response = self.full_dispatch_request()
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1825, in full_dispatch_request
  • 8:08:03 AM rv = self.handle_user_exception(e)
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1823, in full_dispatch_request
  • 8:08:03 AM rv = self.dispatch_request()
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1799, in dispatch_request
  • 8:08:03 AM return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  • 8:08:03 AM File "/app/plex_auto_languages/utils/healthcheck.py", line 27, in __health
  • 8:08:03 AM healthy = self._is_healthy()
  • 8:08:03 AM File "main.py", line 51, in is_healthy
  • 8:08:03 AM return self.alive and self.plex.is_alive
  • 8:08:03 AM File "/app/plex_auto_languages/plex_server.py", line 122, in is_alive
  • 8:08:03 AM return self.connected and self._alert_listener is not None and self._alert_listener.is_alive()
  • 8:08:03 AM File "/app/plex_auto_languages/plex_server.py", line 39, in connected
  • 8:08:03 AM _ = self._plex.library.sections()
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/plexapi/library.py", line 53, in sections
  • 8:08:03 AM self._loadSections()
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/plexapi/library.py", line 41, in _loadSections
  • 8:08:03 AM for elem in self._server.query(key):
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/plexapi/server.py", line 745, in query
  • 8:08:03 AM response = method(url, headers=headers, timeout=timeout, **kwargs)
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 600, in get
  • 8:08:03 AM return self.request("GET", url, **kwargs)
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 587, in request
  • 8:08:03 AM resp = self.send(prep, **send_kwargs)
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 701, in send
  • 8:08:03 AM r = adapter.send(request, **kwargs)
  • 8:08:03 AM File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 578, in send
  • 8:08:03 AM raise ReadTimeout(e, request=request)
  • 8:08:03 AM requests.exceptions.ReadTimeout: HTTPConnectionPool(host='192.168.1.7', port=32400): Read timed out. (read timeout=30)

On Wed, Jul 5, 2023, 8:38 AM Insert Disc @.***> wrote:

I was getting [Warning] Plex closed the websocket connection.

I don't have exact logs to copy as I guess you lose them on a PAL restart.

After restarting Plex I would have to restart PAL as well to restore the connection.

Turns out the issue was a bit deeper. Running maintenance on Plex, having PAL listening and scanning with PMM was causing the server to crash.

I've separated the schedules a bit better to avoid the problem in the future. However, if somebody has a script to restore Plex after a crashed state, the issue with PAL reconnecting would probably still arise. Not something that should happen often, but it's still something that can.

Thank you for your great communication.

On Wed, Jul 5, 2023, 5:10 AM RemiRigal @.***> wrote:

When Plex closes the websocket connection you should have the following logs:

[WARNING] Lost connection to the Plex server [INFO] Trying to restore the connection to the Plex server...

If not, do you have any logs that could indicate a failure ?

— Reply to this email directly, view it on GitHub https://github.com/RemiRigal/Plex-Auto-Languages/issues/81#issuecomment-1621347305, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHSH2JWTVIFUDHWNOF6NN5TXOUVRDANCNFSM6AAAAAAZ42OZLI . You are receiving this because you authored the thread.Message ID: @.***>

InsertDisc avatar Jul 05 '23 12:07 InsertDisc

What version of Plex are you on @InsertDisc

eandrade92630 avatar Oct 20 '23 08:10 eandrade92630

Already an open issue for this: https://github.com/RemiRigal/Plex-Auto-Languages/issues/56

tronyx avatar Mar 23 '24 00:03 tronyx