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

PlexServer()clients() returns nothing #1447

Open
fregapple opened this issue Jul 29, 2024 · 12 comments
Open

PlexServer()clients() returns nothing #1447

fregapple opened this issue Jul 29, 2024 · 12 comments

Comments

@fregapple
Copy link

Describe the Bug

When attempting to return the list of clients connect to the server, I get an empty list for plex media apps.

I am currently using a docker container, using network_mode: "host"

When watching content, the plex dash shows everything is local.

Code Snippets

from plexapi.server import PlexServer
from plexapi.gdm import GDM

baseurl = '192.168.1.77:32400'
token = '<token>'

plex = PlexServer(baseurl, token)
ggg = GDM().all(True)

print(plex.clients())
print(plex.sessions())
print(ggg)

Expected Behavior

print clients, sessions and all GDM

Additional Context

console prints:

[ ]
[TrackSession:2729:Not-for-Me, EpisodeSession:19647:Code-Geass:-Lelouch--s01e11, EpisodeSession:19647:Code-Geass:-Lelouch--s01e11]
[{'data': {'Content-Type': 'plex/media-player', 'Port': '32500', 'Protocol': 'plex', 'Resource-Identifier': '4c5e238c-965d-4dc2-aa22-44bb1376a269', 'Name': "Freg's PlexAmp", 'Version': '4.10.1', 'Product': 'Plexamp', 'Protocol-Version': '1', 'Protocol-Capabilities': 'timeline,playback,playqueues,playqueues-creation', 'Device-Class': 'pc'}, 'from': ('192.168.1.3', 32412)}]

Operating System and Version

Ubuntu 22.04

Plex Media Server Version

1.40.5.8761

Python Version

3.11

PlexAPI Version

current

@fregapple
Copy link
Author

Further information. I installed python and your repo directly into plex docker container and it cannot find the clients there either. It sees the episode sessions, but no clients. If I look at the console within the web app, it shows That it recognizes a Client (As you'd expect cause otherwise I wouldn't be able to play anything.

[Req#ad7f] Client [FD655B2D-F675-49E1-A504-26F231B6F2AA] reporting timeline state playing, progress of 161453/1449447ms for guid=, playbackTime=161402ms ratingKey=19651 url=, key=/library/metadata/19651, containerKey=, metadataId=19651, source=

@JonnyWong16
Copy link
Collaborator

JonnyWong16 commented Jul 29, 2024

Only remote controllable clients will be listed. For example, Plex HTPC will show up because you can remote control it, but Plex Web and Plex for Desktop won't show up because you can't control it.

Some apps (i.e. mobile apps), you need to go into the app settings and enable remote control.

@fregapple
Copy link
Author

on both iOS and tvOS apps I have turned on: Settings --> Remote Control --> Advertise as Player

How ever it still hasn't made them visible

@jjlawren
Copy link
Collaborator

The Plex server must also be on the same subnet as the Plex clients for the SSDP-like multicast protocol to respond properly.

@fregapple
Copy link
Author

I believe they are on the same subnet 192.168.1.0/24

@fregapple
Copy link
Author

Okay, So I just downloaded the windows HTPC version and as soon as I play something on this, it shows up as a client on the server

@fregapple
Copy link
Author

Any ideas? from the exact same phone and server I am able to connect to plexamp and control that client. But not the standard plex client.

@fregapple
Copy link
Author

I got it to briefly work. I signed out, then turned on the announce player setting, then signed back into my account and it worked.

But when I closed the app and reopened it is now not working again

@fregapple
Copy link
Author

fregapple commented Aug 3, 2024

The Plex server must also be on the same subnet as the Plex clients for the SSDP-like multicast protocol to respond properly.

With plex htpc running /clients shows this:

image

Does this indicate that I am on a different subnet as address is 127.0.0.1?

The internal ip of the PC running htpc is 192.168.1.3.

from https://plex.tv/pms/resources.xml:

image

This shows that the iPhone and Apple TV is seen. They are both controllable within HomeAssistant with the plex integration. But they don't show up under /clients, so not controllable with the API. Here it doesn't even show the IP address for the device that HTPC is running on. Instead it has the servers. Compared to the iPhone entry that shows the iPhones local IP

@fregapple
Copy link
Author

It might be worth noting as well, that I can open up PlexAMP on the iphone and cast music to the normal plex app on the iphone, apple tv, htcp. They all appear under casting.

@fregapple
Copy link
Author

fregapple commented Aug 3, 2024

Okay, for anyone who ends up reading this. I can't get clients( ) to work for iOS or tvOS players. However, as I got the above information through resources. I can just manually input the client into my script.

EG

from plexapi.client import PlexClient

iPhoneURL = '<URL found in resources for the client. For me it is http://192.168.1.2:32500/>'
iPhoneID = '<client identifier found in the resources>'

iphone = PlexClient(identifier=iPhoneID, baseurl=iPhoneURL, token='<access token>')

Doing the above I can now control the variable iphone. EG iphone.pause() to pause content playing on the iphone.

@ArjanM83
Copy link

Okay, for anyone who ends up reading this. I can't get clients( ) to work for iOS or tvOS players. However, as I got the above information through resources. I can just manually input the client into my script.

EG

from plexapi.client import PlexClient

iPhoneURL = '<URL found in resources for the client. For me it is http://192.168.1.2:32500/>' iPhoneID = '<client identifier found in the resources>'

iphone = PlexClient(identifier=iPhoneID, baseurl=iPhoneURL, token='<access token>')

Doing the above I can now control the variable iphone. EG iphone.pause() to pause content playing on the iphone.

Thank you for explaining this work around by using the ID.

This issue has been happening for a long time now, see here: https://forums.plex.tv/t/plex-on-apple-tv-4k-2022-wont-announce-as-player-to-be-controlled-from-plex-on-other-devices/819563
Hopefully Plex will fix this.

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

No branches or pull requests

4 participants