Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Cannot connect to Plex #536

Closed
DastardlyDino opened this issue Oct 17, 2023 · 20 comments
Closed

[Question] Cannot connect to Plex #536

DastardlyDino opened this issue Oct 17, 2023 · 20 comments
Labels
question Further information is requested

Comments

@DastardlyDino
Copy link

DastardlyDino commented Oct 17, 2023

Describe the bug
I have my server name, host IP & port correctly filled in. I have authenticated my server with an admin account. I then click "Save Changes". But when I click "Test Saved" I get an error saying "Connection failed! Please check and save your settings". I am able to connect to all my other services (Overseerr, Radarr & Sonarr) just not Plex.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Settings'
  2. Click on 'Plex' in the top ribbon
  3. Fill in 'Name', 'Hostname or IP', 'Port' & Authenticate
  4. Click on 'Save Changes' in the bottom right
  5. Click on 'Test Saved' in the bottom right
  6. See error

Expected behavior
Maintainerr is able to connect to my Plex server

Device:

  • OS: Unraid
  • Version 6.12.4
@jorenn92
Copy link
Owner

Hi,

Are you trying to connect to an internal or external Plex service?

Could you try pinging your hostname or ip from within the Maintainerr container? To rule out network related issues.
Are you sure your Plex port is correct?

@jorenn92 jorenn92 added the question Further information is requested label Oct 19, 2023
@eqjunkie829
Copy link

Also having this issue with my install on Unraid. I'm able to ping the plex ip including port 32400 successfully. This is running on proxynet custom network where all other *arr containers are running. Plex is running on Host network. Also able to successfully Authenticate with Plex however in the container logs it says "WARN [PlexApiService] Plex api communication failure.. Is the application running?"

@jorenn92
Copy link
Owner

I'm unfortunately not familiar with the Unraid community app. I didn't supply it, and to be honest, I actually don't know who did.

Do you know when it was last updated? Is it in sync with the GitHub releases, or is it based on an older version?

If you're able to also run regular containers on your system, you could try to run the image documented in this repo and verify if that version also has this issue.

@DastardlyDino
Copy link
Author

So if I understand how Unraid works it pulls the container from docker-hub and gives you and easy interface for inputting your path, ports, variables, etc. So I am using the latest version that was updated 2 days ago on October 19th. The person who put it in Unraid does not have to maintain the container.
https://imgur.com/a/VOuyMmM

@jorenn92
Copy link
Owner

Thanks for the info! That does sound like it uses the latest image.

When testing this on my setup, I noticed that my browser capitalizes the first letter of the URL. And the server doesn’t normalize it.

Is it possible that’s what’s going on here? Is the first letter capitalized?

@DastardlyDino
Copy link
Author

I'm a little confused by "capitalizes the first letter of the URL". I am using my internal IP address to try and connect to my Plex server. Is that not the correct way of doing it?

Side note my server name is two words like "Server Name". Not sure if that makes a difference.

https://imgur.com/a/SDT1sNL

@jorenn92
Copy link
Owner

If you're just using the IP, you can ignore my previous comment. I figured that you might be using 'http(s)://' in front of your URL, and when that's capitalized, something might go wrong.

The Plex name variable is actually not used (yet). This was added to keep the possibility open for a multiple Plex server feature in the future. Multiple words shouldn't be a problem here.

It puzzles me why you're having this issue. Your configuration seems fine from Maintainerr's standpoint. All I can think of is that Maintainerr isn't in the same subnet, or can't reach the Plex instance for some other reason.

Could you try to execute this command on your docker host machine where the Maintainerr container is running? Replace <container_name> with the name you gave your Maintainerr instance.

 docker exec -ti <container_name> wget 192.168.10.6:32400

This should return "wget: server returned error: HTTP/1.1 401 Unauthorized". That means something is running on the other side and we can reach it.

If it says "wget: can't connect to remote host (): Connection refused", that means the Maintainerr container can't reach Plex.

@DastardlyDino
Copy link
Author

Sorry for the delay. Looks like Maintainerr can't connect to Plex and I have no idea why. They're on the same docker network.
https://imgur.com/a/BZic23n

@jorenn92
Copy link
Owner

No problem!
Did you try the commands from my previous comment?

You could also try to configure the Plex container name in the ‘hostname’ field instead of the Ip address.

@jorenn92
Copy link
Owner

jorenn92 commented Oct 31, 2023

In discussion #561, it came to my attention that Plex communication fails if you configured Plex to require secure connections. Is it possible that this is the issue?

If so, you could change the 'secure connections' flag to 'Preferred' instead of 'Required'. If you really want Maintainerr to communicate over the Plex redirect URL, you could fetch this URL from the Plex web network calls and configure it in Maintainerr (https:// included).

@DastardlyDino
Copy link
Author

DastardlyDino commented Nov 6, 2023

No problem! Did you try the commands from my previous comment?

You could also try to configure the Plex container name in the ‘hostname’ field instead of the Ip address.

Yes I did run the commands in your previous post. See the first image in the linked image.


In discussion #561, it came to my attention that Plex communication fails if you configured Plex to require secure connections. Is it possible that this is the issue?

If so, you could change the 'secure connections' flag to 'Preferred' instead of 'Required'. If you really want Maintainerr to communicate over the Plex redirect URL, you could fetch this URL from the Plex web network calls and configure it in Maintainerr (https:// included).

So it looks like you were right. If I change the Network settings inside of Plex to "Prefer" secure connections instead of "Require" that fixes the issue. But I am a bit confused by your instructions if I would like to keep the secure connection setting in Plex to "Required". What are the Plex web network calls? How do I find them?

@jorenn92
Copy link
Owner

jorenn92 commented Nov 7, 2023

Hey, good to hear this issue occurs due to the secure connection settings. Plex uses some magic to enable secure communication between clients and your local server. It'll create a unique secure URL for your server, containing your local IP and a unique hash.

This unique URL could be used as the hostname inside Maintainerr to enable secure communication. I'm planning to implement the same fetching mechanism as Overseerr (there, you can load your secure urls in Plex settings), but until then, you'll have to fetch it manually.

To fetch it manually, you'll have 2 options. Option 1 being the easiest

Option 1:
Open Overseerr, navigate to Plex settings and load your servers. Click on your secure '*.plex.direct' url and copy the value over to Maintainerr. You're probably already using this address, since Overseerr worked when Plex required secure connections.

Option 2:
Open Plex web on your pc/mac and navigate to any media page on your server, right click anywhere on the page, then click 'inspect'.

In the inspector, navigate to network. Then open something on Plex web (i.e. media details), you'll see the network calls Plex makes. Then find a 'GET' call that went to this kind of address: https://192-168-0-1.qsdgsdsgfdhdfh1dfhdfrh8hfdhqslmd.plex.direct:32400 (this is a dummy, your URL will look different, but it'll contain your local IP, a unique hash, and your Plex port).

This is the address you want. Copy the 'https://192-168-0-1.qsdgsdsgfdhdfh1dfhdfrh8hfdhqslmd.plex.direct' part in Maintainerr's hostname field and the '32400' in the 'port' field.

When you're using this address, you can change the 'secure connections' flag back to 'required'

@jorenn92 jorenn92 changed the title Cannot connect to Plex [Question] Cannot connect to Plex Nov 30, 2023
@davenasty
Copy link

I just started looking into Maintainerr yesterday. It looks like it connected to Plex correctly when I am configuring and authenticating. I can see my movies in Maintainerr but when I run a rule I am seeing the same thing as the above post.

"WARN [PlexApiService] Plex api communication failure.. Is the application running?

I have set the secure connections to preferred within Plex and I also tried using the secure address as the hostname with the remote port. In both instances the application authenitcated to plex correctly but errors when I run a rule.

My rule is currently looking for a specific playlist. I can see the GET requests in the Plex console requesting playlists and returning a 200 response.

Please let me know if you have any ideas or if there are any more details I can provide.

Thank you!

@jorenn92
Copy link
Owner

jorenn92 commented Jan 5, 2024

I just started looking into Maintainerr yesterday. It looks like it connected to Plex correctly when I am configuring and authenticating. I can see my movies in Maintainerr but when I run a rule I am seeing the same thing as the above post.

"WARN [PlexApiService] Plex api communication failure.. Is the application running?

I have set the secure connections to preferred within Plex and I also tried using the secure address as the hostname with the remote port. In both instances the application authenitcated to plex correctly but errors when I run a rule.

My rule is currently looking for a specific playlist. I can see the GET requests in the Plex console requesting playlists and returning a 200 response.

Please let me know if you have any ideas or if there are any more details I can provide.

Thank you!

Hey! This seems more like a functional error. Coincidentally, I've been adding debug logs today. If you're willing to try the 'develop' docker tag, you could add 'DEBUG=true' as an environment variable to your docker compose. This should enable more logs, and hopefully, show the exact error message.

@davenasty
Copy link

Thank you for this fast response. Here is what I am showing in the debug logs.

Error: Cannot read properties of undefined (reading 'filter')

image

@jorenn92
Copy link
Owner

jorenn92 commented Jan 5, 2024

Thank you for this fast response. Here is what I am showing in the debug logs.

Error: Cannot read properties of undefined (reading 'filter')

image

Aha, that’s an actual code error. I’ll fix it later this weekend. Thank you for reporting it!

@jorenn92
Copy link
Owner

jorenn92 commented Jan 6, 2024

Thank you for this fast response. Here is what I am showing in the debug logs.

Error: Cannot read properties of undefined (reading 'filter')

image

I pushed a fix in #716. It'll be available in the next release.

I'll close this issue since the original question hasn't received a reply for a while. If you still encounter issues after the next release, feel free to create a new issue. Thanks for your report!

@jorenn92 jorenn92 closed this as completed Jan 6, 2024
@smurfster
Copy link

Hey, good to hear this issue occurs due to the secure connection settings. Plex uses some magic to enable secure communication between clients and your local server. It'll create a unique secure URL for your server, containing your local IP and a unique hash.

This unique URL could be used as the hostname inside Maintainerr to enable secure communication. I'm planning to implement the same fetching mechanism as Overseerr (there, you can load your secure urls in Plex settings), but until then, you'll have to fetch it manually.

To fetch it manually, you'll have 2 options. Option 1 being the easiest

Option 1: Open Overseerr, navigate to Plex settings and load your servers. Click on your secure '*.plex.direct' url and copy the value over to Maintainerr. You're probably already using this address, since Overseerr worked when Plex required secure connections.

Option 2: Open Plex web on your pc/mac and navigate to any media page on your server, right click anywhere on the page, then click 'inspect'.

In the inspector, navigate to network. Then open something on Plex web (i.e. media details), you'll see the network calls Plex makes. Then find a 'GET' call that went to this kind of address: https://192-168-0-1.qsdgsdsgfdhdfh1dfhdfrh8hfdhqslmd.plex.direct:32400 (this is a dummy, your URL will look different, but it'll contain your local IP, a unique hash, and your Plex port).

This is the address you want. Copy the 'https://192-168-0-1.qsdgsdsgfdhdfh1dfhdfrh8hfdhqslmd.plex.direct' part in Maintainerr's hostname field and the '32400' in the 'port' field.

When you're using this address, you can change the 'secure connections' flag back to 'required'

sadly this doesnt work for me, If I try the blahblah.plex.direct:32400 address in a browser it works fine, If I set plex to prefer secure it works.

logs just state " WARN [PlexApiService] Plex api communication failure.. Is the application running?"

Im using the latest which I assume is 1.7.1

@jorenn92
Copy link
Owner

Hey, good to hear this issue occurs due to the secure connection settings. Plex uses some magic to enable secure communication between clients and your local server. It'll create a unique secure URL for your server, containing your local IP and a unique hash.
This unique URL could be used as the hostname inside Maintainerr to enable secure communication. I'm planning to implement the same fetching mechanism as Overseerr (there, you can load your secure urls in Plex settings), but until then, you'll have to fetch it manually.
To fetch it manually, you'll have 2 options. Option 1 being the easiest
Option 1: Open Overseerr, navigate to Plex settings and load your servers. Click on your secure '*.plex.direct' url and copy the value over to Maintainerr. You're probably already using this address, since Overseerr worked when Plex required secure connections.
Option 2: Open Plex web on your pc/mac and navigate to any media page on your server, right click anywhere on the page, then click 'inspect'.
In the inspector, navigate to network. Then open something on Plex web (i.e. media details), you'll see the network calls Plex makes. Then find a 'GET' call that went to this kind of address: https://192-168-0-1.qsdgsdsgfdhdfh1dfhdfrh8hfdhqslmd.plex.direct:32400 (this is a dummy, your URL will look different, but it'll contain your local IP, a unique hash, and your Plex port).
This is the address you want. Copy the 'https://192-168-0-1.qsdgsdsgfdhdfh1dfhdfrh8hfdhqslmd.plex.direct' part in Maintainerr's hostname field and the '32400' in the 'port' field.
When you're using this address, you can change the 'secure connections' flag back to 'required'

sadly this doesnt work for me, If I try the blahblah.plex.direct:32400 address in a browser it works fine, If I set plex to prefer secure it works.

logs just state " WARN [PlexApiService] Plex api communication failure.. Is the application running?"

Im using the latest which I assume is 1.7.1

Could you provide a screenshot of the input you attempted?

Alternatively, on the develop (or main on ghcr.io) image, there's a select box available that allows you to search for servers. You should be able to select your preferred secure server from there. This feature will also be included in the upcoming release, expected somewhere this week.

@t34wrj
Copy link

t34wrj commented Feb 4, 2024

I also have the same error, running 2.0.0. Plex authenticates but whichever of the three servers I select results in these errors:

[maintainerr] | 04/02/2024 18:17:18 [WARN] [PlexApiService] Plex api communication failure.. Is the application running?
[maintainerr] | 04/02/2024 18:17:18 [DEBUG] [PlexApiService] Cannot read properties of undefined (reading 'machineIdentifier')
[maintainerr] | 04/02/2024 18:17:20 [WARN] [PlexApiService] Plex api communication failure.. Is the application running?
[maintainerr] | 04/02/2024 18:17:20 [DEBUG] [PlexApiService] Cannot read properties of undefined (reading 'MediaContainer')
[maintainerr] | 04/02/2024 18:17:20 [DEBUG] [SettingsService] Cannot read properties of undefined (reading 'version')
[maintainerr] | 04/02/2024 18:19:47 [INFO] [SettingsService] Settings updated
[maintainerr] | 04/02/2024 18:19:47 [WARN] [PlexApiService] Plex api communication failure.. Is the application running?
[maintainerr] | 04/02/2024 18:19:47 [DEBUG] [PlexApiService] Cannot read properties of undefined (reading 'MediaContainer')
[maintainerr] | 04/02/2024 18:19:47 [WARN] [PlexApiService] Plex api communication failure.. Is the application running?
[maintainerr] | 04/02/2024 18:19:47 [DEBUG] [PlexApiService] Cannot read properties of undefined (reading 'machineIdentifier')
[maintainerr] | 04/02/2024 18:19:48 [WARN] [PlexApiService] Plex api communication failure.. Is the application running?
[maintainerr] | 04/02/2024 18:19:48 [DEBUG] [PlexApiService] Cannot read properties of undefined (reading 'MediaContainer')
[maintainerr] | 04/02/2024 18:19:48 [DEBUG] [SettingsService] Cannot read properties of undefined (reading 'version')

This even happens for the server address that works in Overseerr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants