python-plexapi
python-plexapi copied to clipboard
PlexServer()clients() returns nothing
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
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=
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.
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
The Plex server must also be on the same subnet as the Plex clients for the SSDP-like multicast protocol to respond properly.
I believe they are on the same subnet 192.168.1.0/24
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
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.
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
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:
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:
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
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.
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.
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.