python-plexapi icon indicating copy to clipboard operation
python-plexapi copied to clipboard

Connect() Failing, Manual Chrome Access Works

Open arrmo opened this issue 1 year ago • 2 comments

Describe the Bug

Hi,

This may be me, but 😆. I am connecting to my Plex server - actually, trying to open a connection to each one (for monitoring), but even just one - it's failing. Some of the connections will (not sure why every IP is showing up!), but I have manually gone to Chrome, and I can connect. Code shown below.

Thanks!

Code Snippets

try:
    logging.info('Connecting to Plex Account ...')
    account = MyPlexAccount('email', 'password')
    logging.info('Connected. Now enumerating servers (automatically)')
    for resource in account.resources():
        server: PlexServer = resource.connect(timeout=1)

Expected Behavior

I would expect this to connect. If I use account.resources()[1], and concatenate uri and ?X-Plex-Token=XXXXX ... it works fine (from Chrome). But, it fails from the code above. It seems like it is only trying the first connection on this list. I say that because ... there are 6 connections => [0] fails (as it should), but [1] should work. But, I get an exception after 1 second, so it's only trying the first connection.

Additional Context

No response

Operating System and Version

Ubuntu, 22.04

Plex Media Server Version

1.32.0.6918

Python Version

3.9.12

PlexAPI Version

4.13.4

arrmo avatar Apr 16 '23 02:04 arrmo

Wrap the try: only around the resource.connect() call so that the loop can continue.

jjlawren avatar Apr 16 '23 02:04 jjlawren

Actually, fiddling in parallel ... it seems to work if I set the server to Secure connections Required, but fails if Preferred. Make sense?

Thanks!

arrmo avatar Apr 16 '23 02:04 arrmo