ajnart / homarr

Customizable browser's home page to interact with your homeserver's Docker containers (e.g. Sonarr/Radarr)
https://homarr.dev
MIT License
6.19k stars 285 forks source link

Plex widget not 'working' #739

Closed MrMxyzptlk closed 1 year ago

MrMxyzptlk commented 1 year ago

Environment

Docker

Version

0.11.5

Describe the problem

Already had Plex app added in Homarr. Edited to add Plex widget 'service' to Homarr, as well as the media widget. Put correct token from XML in Homarr. Plex badge in media widget surrounded by red circle, and no media shows when I'm playing in Plex. I am logged into plex.tv in Plex.

Additional info

No response

Please tick the boxes

manuel-rw commented 1 year ago

Hi. Can you check that all "Common issues" do not apply to your configuration? https://homarr.dev/docs/widgets/media-server#common-issues

MrMxyzptlk commented 1 year ago

Thank you almost all of those apply. I'll go ahead and close this and change how I have the u r l and the credentials

manuel-rw commented 1 year ago

Awesome. We'll implement an automatic- bad URL detection in the future for Plex, since this mistake is made so often. I think I'll pin this, as there are most likely more users with the same question

wiston81 commented 1 year ago

Same for me. Error from log

ERROR failed to communicate with media server 'Plex' (11dbc21c-5292-4ddf-8d7d-3db500310d95): FetchError: request to http://192.168.1.200:32400/status/sessions?X-Plex-Token=** failed, reason: socket hang up

manuel-rw commented 1 year ago

Same for me. Error from log

ERROR failed to communicate with media server 'Plex' (11dbc21c-5292-4ddf-8d7d-3db500310d95): FetchError: request to http://192.168.1.200:32400/status/sessions?X-Plex-Token=** failed, reason: socket hang up

That's definitely an issue on your side. Most likely Proxy, Network issue or something like that

manuel-rw commented 1 year ago

Can we close this issue?

MrMxyzptlk commented 1 year ago

It still doesn't work for me. The 'red' ring around the badge has gone away since I switched to https://192.168.50.174:32400 vs https://app.plex.tv:32400; however I grabbed a token from the XML using the first URL and it still doesn't show anything playing in the widget. Emby was fixed and shows playing when I changed to the local URL from https://app.emby.media:8096

manuel-rw commented 1 year ago

ALWAYS use the local URL. Do not use a public/ remote access URL for all of the media servers (Jellyfin, Plex, Emby). If the red circle went away, it should work. If you still see no sessions, check the log of Homarr.

Also note, that the media server widget does not display the items being played, but the active sessions. Some third party clients may not report the content, that they are currently playing, correctly to the server.

yeeahnick commented 1 year ago

I get a red circle on the plex badge in the widget. Logs say this:

ERROR failed to communicate with media server 'Plex' (f6adc34d-ea3c-4da8-bff4-b68214794007): FetchError: request to https://192.168.1.6:32400/web/status/sessions?X-Plex-Token=***** failed, reason: Hostname/IP does not match certificate's altnames: IP: 192.168.1.6 is not in the cert's list:

Edit: I can get rid of the red badge and error if I set Plex secure connections to "preferred" instead of "required". Also had to remove the /web at the end of the link but that breaks the online status of the Homarr network/online status for the Plex tile. The widget is now showing the active sessions.

Ideally I would prefer to keep secure connections to "required". I know Tautulli has an option for that which works perfectly.

manuel-rw commented 1 year ago

Ideally I would prefer to keep secure connections to "required". I know Tautulli has an option for that which works perfectly.

Then you need to fix the certificate error. It's quite obvious from the log: Hostname/IP does not match certificate's altnames: IP: 192.168.1.6 is not in the cert's list.

Perhaps this guide also works for your issue? https://homarr.dev/docs/advanced/proxies-and-certificates

yeeahnick commented 1 year ago

Ideally I would prefer to keep secure connections to "required". I know Tautulli has an option for that which works perfectly.

Then you need to fix the certificate error. It's quite obvious from the log: Hostname/IP does not match certificate's altnames: IP: 192.168.1.6 is not in the cert's list.

Perhaps this guide also works for your issue? https://homarr.dev/docs/advanced/proxies-and-certificates

I would if I actually used an external cert... What's being blocked here is the cert provided by plex when forcing HTTPS. Like I said, Tautulli has a option to enable HTTPS communication with Plex and it works perfectly without "fixing the cert".

manuel-rw commented 1 year ago

Can you create an issue for this? This problem is not related anymore with the original problem here. Sadly, I don't have time to fix this issue, nor do I actively run Plex.

It would be great if you could provide how your Plex is configured (only relevant information to reproduce this problem) in the new issue.

yeeahnick commented 1 year ago

Can you create an issue for this? This problem is not related anymore with the original problem here. Sadly, I don't have time to fix this issue, nor do I actively run Plex.

It would be great if you could provide how your Plex is configured (only relevant information to reproduce this problem) in the new issue.

Will do thank you. I posted it here because I know some folks are still having issues. They most likely have secure connections set to "required" in plex.

yeeahnick commented 1 year ago

Okay well sorry for all this. NODE_TLS_REJECT_UNAUTHORIZED=0 seems to have done the trick! The online status of the plex tile is still red since /web is missing from the URL but I can live with that.

manuel-rw commented 1 year ago

Okay well sorry for all this. NODE_TLS_REJECT_UNAUTHORIZED=0 seems to have done the trick! The online status of the plex tile is still red since /web is missing from the URL but I can live with that.

Awesome! You could add the status code to the accepted code list, but they seem to be broken: #726

yeeahnick commented 1 year ago

Okay well sorry for all this. NODE_TLS_REJECT_UNAUTHORIZED=0 seems to have done the trick! The online status of the plex tile is still red since /web is missing from the URL but I can live with that.

Awesome! You could add the status code to the accepted code list, but they seem to be broken: #726

Thanks for the tip but I tried them all. The plex link without /web that is needed for the widget brings me to some sort of XML config file. It doesn't give me any timeout errors because the link is accessible which is probably why the status codes dont do anything. I am still on 0.11.5 though maybe that is fixed in 0.11.6

Any how, thanks for everything!

spencerthayer commented 1 year ago

Experiencing the same issue. None of the token URLs work.

manuel-rw commented 1 year ago

Do not append the token to the URL. Set the token as the secret in the credentials of your Plex app. Your URL should not end with /

Vandekieft commented 1 year ago

I had to:

spencerthayer commented 1 year ago

Thanks for the help, still not working.

joshoram80 commented 1 year ago
03/20/2023 7:36:18 PM
 ERROR  failed to communicate with media server 'Your app' (7e003440-a625-471d-9c3a-6b63741d0a60): Error: Unexpected close tag
03/20/2023 7:36:18 PM
Line: 18
03/20/2023 7:36:18 PM
Column: 1458
03/20/2023 7:36:18 PM
Char: >
03/20/2023 7:36:18 PM

Same here. API-Key is added. Using :32400 for Internal IP. Still get red circle.

Funny thing. It's still referring to 'Your app', when the App is titled 'Plex' in the settings

Something is very wrong here. Don't see how this issue is 'Closed' if people are still having issues. Back to Homepage until this is sorted out. Shame :(

EDIT: SO checking the default.json config file.

"integration": {
        "type": "plex",
        "properties": [
          {
            "field": "apiKey",
            "type": "private",
            "value": "XXXXXXXXX"
          }

the key value is not the API Key I pasted into the settings. It's actually story the External Address (without the https://). I manually edited the file and added the correct API Key but it's still busted.

manuel-rw commented 1 year ago

You are right, we'll reopen this issue.

the key value is not the API Key I pasted into the settings. It's actually story the External Address (without the https://).

That is very weird. So it contained your plex hostname / IP instead of the actual API key? And you manually entered the correct token now I assume? Can you maybe provide me with your Plex version? Do you have any proxies in place (Ngingx, Authelia, ...)?

manuel-rw commented 1 year ago

Experiencing the same issue. None of the token URLs work.

Sorry for my late reply. Please remove /?X-Plex-Token=TOKENVALUE-HERE from your URL. The API token should not be appended after the URL, but should be set as a secret in the app itself:

  1. Edit your Plex app
  2. Go to the integrations tab
  3. Edit the api key secret
  4. Save your app
  5. Exit edit mode to save your changes
joshoram80 commented 1 year ago

Yes I entered the API key into settings, but in the default.json file where the API key should have been was 'plex.mydomain.tld'

I'm using the latest official Plex container on Unraid, running behind Traefik (as are all my containers. I currently use Homepage as a backup and it has Plex integration as well and it works fine.)

manuel-rw commented 1 year ago

Can you confirm, that none of these cases apply? https://homarr.dev/docs/widgets/media-server#common-issues

If you use Traefik with a hostname, ensure that it does not end with / and ends with the basepath of Plex. Examples:

https://myhost/plex https://myhost:8912

joshoram80 commented 1 year ago

None of those apply as far as I can tell. Plex is accessible at http://plex.my.domain but I only have that set as the remote URL. The internal IP is the IP address of the Unraid server and is accessible from the homarr container. Ping is fine.

On Mon, 20 Mar 2023, 10:46 pm Manuel, @.***> wrote:

Can you confirm, that none of these cases apply? https://homarr.dev/docs/widgets/media-server#common-issues

If you use Traefik with a hostname, ensure that it does not end with / and ends with the basepath of Plex. Examples:

https://myhost/plex https://myhost:8912

— Reply to this email directly, view it on GitHub https://github.com/ajnart/homarr/issues/739#issuecomment-1476078864, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAP7FG2KVNX5WFTQX633O43W5A7QDANCNFSM6AAAAAAVJS5WYM . You are receiving this because you commented.Message ID: @.***>

manuel-rw commented 1 year ago

The remote (or external address) doesn't matter in this case.

The internal IP is the IP address of the Unraid server

Does the internal IP redirect you to Plex? The internal one will be used for the API communication and it must satisfy all requirements documented in the link above.

joshoram80 commented 1 year ago

Yes it does, and when i set a ping it shows green. The only reason I mentioned the remote address is that that value was being stored in the config file where the API key should be for some reason. I have the to add the token manually.

On Mon, 20 Mar 2023, 11:45 pm Manuel, @.***> wrote:

The remote, or external address, doesn't matter in this case.

The internal IP is the IP address of the Unraid server

Does the internal IP redirect you to Plex? The internal one will be used for the API communication and it must satisfy all requirements documented in the link above.

— Reply to this email directly, view it on GitHub https://github.com/ajnart/homarr/issues/739#issuecomment-1476171373, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAP7FG2HQZJKRSMRKT5X5X3W5BGQHANCNFSM6AAAAAAVJS5WYM . You are receiving this because you commented.Message ID: @.***>

brianramseyau commented 1 year ago

I too am having this issue, regardless how I do the config, the sessions just do not show up. All testing shows I have done this correctly but alas, no dice :(

config excerpt:

image

wget from inside the container works to the sessions endpoint using the auth token I have provided in the config:

image

It's also showing the ping as failing if I have it on, with a 401 - Unauthorized when using the root URL:

image

There are no errors showing in stdout/stderr. The plex icon does not have a red ring.

Have tried the following clients/media:

Homarr: 0.11.5 Plex: 1.32.0.6918 (linuxserver.io container)

manuel-rw commented 1 year ago

Hi, thanks for the information. Are there any errors in Homarr's log?

brianramseyau commented 1 year ago

Thanks for the reply @manuel-rw there are no errors in the logs

image
manuel-rw commented 1 year ago

Okay, thanks. I think I know that's going on here. Since there is no error in the log, we can assume that everything is working as intended. In your wget, I can see that there's no <Session /> element.

For this widget, we require the following elements to be present:

This can be seen here: https://github.com/ajnart/homarr/blob/632a9967fdbbbcf213e8416e54e3665f9a8cff66/src/tools/server/sdk/plex/plexClient.ts#L31-L34

If one of those elements is not present, we do not process that session:

https://github.com/ajnart/homarr/blob/632a9967fdbbbcf213e8416e54e3665f9a8cff66/src/tools/server/sdk/plex/plexClient.ts#L36-L38

I am a Jellyfin user, and only ran Plex for creating this widget. During that testing, all of those elements were present. Did you redact / censor elements, expect the contents of <Track/>, <User/> and <Player/>? If not, there might be a reason why your Plex does not expose the session information.

Do you have any special settings? I quickly spun up my Plex, and can you check your Plex Web Version, located here: <your-hostname>/web/index.html#!/settings/web/general? Mine is different from your 1.32.0.6918, but that might not be the same number.

brianramseyau commented 1 year ago

Thank you for the response. I did not redact anything besides the covering of items, however that was PlexAmp only so my next example will contain a webUI playback client as well (easiest while on PC)

As I have proved the connection working I have swapped to browser for further debugging info. I have tried to only redact the content and not the XML keys to assist here.

image

With both of these sessions, this is the widget

image

Plex maintains separate versions for their server and webUi, so for my current install I have: WebUI Version: 4.100.1 (/settings/web/general) Server Version: 1.32.0.6918 (/settings/server//settings/general)

As far as special settings, I do not really, it's a long-time install I haven't really touched in years... Seems like the clients have different attributes that may need to be catered for. I'm totally fine that PlexAmp doesn't work, but the WebUI with direct connection to the server, and other devices like the TV and phones and stuff I thought would work...

brianramseyau commented 1 year ago

Okay, further debugging this morning has presented the following findings:

  1. PlexAmp doesn't show anything (local/cloud connect) That is fine, clearly not made to work with this (does not present <Session> at all)

  2. Direct connection does not work (local server IP connections) This is from my debugging, that the <User> key is empty in these sessions (presented self-closing as <User/>), this is problematic (in my opinion) as direct connections shouldn't be an issue, pretty common in a local-first setup.

  3. In order to have the Direct connect setup I have this attribute setup, allowing direct unauthed connections from local devices, this is relatively common and allows you to use Plex locally when your internet is down (Yay, Australian internet...)

    image

Do I think that direct connections should be okay? yes... Is it a bug? I mean that depends on the intended purpose of the widget and it's design constraints :)

If it's a limitation I suggest updating the FAQ to say that direct connections (to server using IP, etc) are not supported and you have to be using a logged-in plex.tv authorised account. This also means you cannot see server-managed sessions (local users) activities either.

manuel-rw commented 1 year ago

Thanks for the detailed information and your debugging. This helps a lot and makes life much easier!

  1. I suspect, that PlexAmp does not open a session at Plex at all. It only "reports" the player's capabilities to Plex. Seems like <Session/> seems to be optional. I'll implement that
  2. I think <User /> will be empty (self-enclosing) if you're anonymous -> allowing direct unauthed connections from local devices, this is relatively common and allows you to use Plex locally when your internet is down. I will implement that too

Is it a bug? I mean that depends on the intended purpose of the widget and it's design constraints :)

Yes, definitely a bug. Sadly, there is barely any API documentation for Plex - so we just assumed things. Seems like we didn't get things quite right.

I will make the following changes to the widget:

brianramseyau commented 1 year ago

Thank you so much @manuel-rw I'm glad that my information was useful.

manuel-rw commented 1 year ago

I built a Docker test image in 5ae6b39fa9404b420171c2e53bf65208327d4acf . Can you backup your configuration and switch to the image tag :test-anonymous-plex. Are your issues resolved there?

manuel-rw commented 1 year ago

This was merged to 0.12. Can you check if it's working now?

brianramseyau commented 1 year ago

Sorry for the delay @manuel-rw, I was away over the weekend. I have pulled latest and PlexAmp and the local connections are now showing up

image

Thank you so much for the prompt fix :)

manuel-rw commented 1 year ago

amazing, nice to hear. Did this fix the issue for the others here too?

manuel-rw commented 1 year ago

I'm marking this as resolved. If any of the participants here still has this issue, please let me know so we can reopen.