RemiRigal/Plex-Auto-Languages

[ERROR] Connection to the Plex server failed for user

Opened this issue · 8 comments

For some reason there are regular connection errors for the shared users in my plex home in the logs.
Although this is not always the case, as it shows that there have been language changes for some.

I set up the Docker container on the same windows machine my plex server runs on. I used the Docker compose minimal configuration.
I have attached some log files, maybe you understand where these errors are coming from. Also attached the yaml file (as a .txt file as github doesnt let you upload yaml files).

I was able to trigger language changes remotely with the android app on my phone over the mobile network.
Most other users access the server remotely.

Best Regards.

Logs Plex Auto Languages.txt
Logs Plex Auto Languages1.txt
docker-compose.yaml.txt

EDIT: Okay, seems i only get errors now altthough as you can see in the attached picture there is one time when the app changed the language settings for one user
image

Must be something about using it in a docker container i guess as I'm now running it with python and don't have this issue there.

I believe this issue is due to the docker using an older version of the plexapi package. I found this commit where it's clear a previous update attempt caused a problem. I went through the requirements.txt file and checked all of the listed dependencies, building the docker image and running it worked perfectly for me updating each of these to the latest versions available:

plexapi>=4.13.2
websocket-client>=1.5.1
apprise>=1.2.1
PyYAML>=6.0
schedule>=1.1.0
Flask>=2.2.3
python-dateutil>=2.8.2
tqdm>=4.64.1
requests>=2.28.2

I do not know the project well enough to be certain that it's sensible to update them all, but it's running well on my machine with these versions set.

I believe this issue is due to the docker using an older version of the plexapi package. I found this commit where it's clear a previous update attempt caused a problem. I went through the requirements.txt file and checked all of the listed dependencies, building the docker image and running it worked perfectly for me updating each of these to the latest versions available:

plexapi>=4.13.2
websocket-client>=1.5.1
apprise>=1.2.1
PyYAML>=6.0
schedule>=1.1.0
Flask>=2.2.3
python-dateutil>=2.8.2
tqdm>=4.64.1
requests>=2.28.2

I do not know the project well enough to be certain that it's sensible to update them all, but it's running well on my machine with these versions set.

Thank you for your precious feedback on this. The plexapi rollback I did in September was actually because they dropped support for Python 3.6 in version 4.12.0 and I wanted to maintain the support for this version. I guess that it's reasonable to drop it now considering the numerous updates of the plexapi package.

I will test the versions you suggested and update the requirements.txt file on the master branch if all the tests are passing.

I unfortunately need to come back to add that I spoke too soon. My build using those updated dependencies does run, but after leaving it overnight I'm seeing the same "Connection to the Plex server failed for user 'X'" error. I do want to say also, I appreciate this tool and your effort in making it.

I have a theory on the root cause of this issue. I think it has to do with this connection test.

_ = self._plex.library.sections()

For me server this test is performed very frequently, 1-3 times every ten seconds. Granted, I do have a large number of users. The issue seems to be that this test being called frequently is acting unreliably. It may be a rate limiting feature of Plex itself though I can't find that documented. Regardless, when I modified this test to a more simple test

_ = self._plex.getWebURL()

It entirely eliminated my problem. I went with that function as the test as it required very little from the server and if a user is connected then they must have a valid URL... but I am not confident it is necessarily the best option. It might be worth reconsidering if that specific test should be where it is as it seems to fire off very often.

Thank you for the thorough investigation @phobiac, I think that you are correct.
However, using the getWebURL function is not sufficient as it only builds the URL to the server but does not perform any requests. See here for details.
I may need to add cache for the user instances to prevent the library.sections() request from being called this often.

Ah! You're right, I figured that wasn't an ideal test. If you need someone to QA a potential update for a proper fix feel free to reach out to me, I appreciate this tool quite a bit.

any update on this? i'm having the same issue where only specific users are receiving an error. also running it in docker and it occurs whether the user is on the local network on connecting remotely.