luigi311 / JellyPlex-Watched

Sync watched between jellyfin and plex locally
GNU General Public License v3.0
366 stars 19 forks source link

[BUG]Unable to Login to Plex #162

Closed rammjet closed 3 months ago

rammjet commented 3 months ago

Describe the bug Running docker-compose, unable to login. Error seems to imply a bad url: Max retries exceeded with url: /

To Reproduce Create docker-compose.yml and .env files Run "docker compose up"

Expected behavior Expected JellyPlex dry run

Logs Having trouble finding where the log is written. Using console output.

@rammjet-TH50:/docker/jellyplex# docker compose up
[+] Running 1/1
 ✔ jellyplex-watched Pulled                                                                                                    0.4s 
[+] Running 1/1
 ✔ Container jellyplex-watched  Recreated                                                                                      0.1s 
Attaching to jellyplex-watched
jellyplex-watched  | [INFO]: Dryrun: True
jellyplex-watched  | [INFO]: Creating (black/white)lists
jellyplex-watched  | [INFO]: Blacklist Library: []
jellyplex-watched  | [INFO]: Blacklist Library Type: []
jellyplex-watched  | [INFO]: Blacklist Users: []
jellyplex-watched  | [INFO]: Whitelist Library: []
jellyplex-watched  | [INFO]: Whitelist Library Type: []
jellyplex-watched  | [INFO]: Whitelist Users: ['rammjet']
jellyplex-watched  | [INFO]: Creating server connections
jellyplex-watched  | [ERROR]: Plex: Failed to login, Error: HTTPConnectionPool(host='localhost', port=32400): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f915e24be10>: Failed to establish a new connection: [Errno 111] Connection refused'))
jellyplex-watched  | [ERROR]: HTTPConnectionPool(host='localhost', port=32400): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f915e24be10>: Failed to establish a new connection: [Errno 111] Connection refused'))
jellyplex-watched  | [ERROR]: Traceback (most recent call last):
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 203, in _new_conn
jellyplex-watched  |     sock = connection.create_connection(
jellyplex-watched  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 85, in create_connection
jellyplex-watched  |     raise err
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 73, in create_connection
jellyplex-watched  |     sock.connect(sa)
jellyplex-watched  | ConnectionRefusedError: [Errno 111] Connection refused
jellyplex-watched  | 
jellyplex-watched  | The above exception was the direct cause of the following exception:
jellyplex-watched  | 
jellyplex-watched  | Traceback (most recent call last):
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 790, in urlopen
jellyplex-watched  |     response = self._make_request(
jellyplex-watched  |                ^^^^^^^^^^^^^^^^^^^
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 496, in _make_request
jellyplex-watched  |     conn.request(
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 395, in request
jellyplex-watched  |     self.endheaders()
jellyplex-watched  |   File "/usr/local/lib/python3.11/http/client.py", line 1289, in endheaders
jellyplex-watched  |     self._send_output(message_body, encode_chunked=encode_chunked)
jellyplex-watched  |   File "/usr/local/lib/python3.11/http/client.py", line 1048, in _send_output
jellyplex-watched  |     self.send(msg)
jellyplex-watched  |   File "/usr/local/lib/python3.11/http/client.py", line 986, in send
jellyplex-watched  |     self.connect()
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 243, in connect
jellyplex-watched  |     self.sock = self._new_conn()
jellyplex-watched  |                 ^^^^^^^^^^^^^^^^
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 218, in _new_conn
jellyplex-watched  |     raise NewConnectionError(
jellyplex-watched  | urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f915e24be10>: Failed to establish a new connection: [Errno 111] Connection refused
jellyplex-watched  | 
jellyplex-watched  | The above exception was the direct cause of the following exception:
jellyplex-watched  | 
jellyplex-watched  | Traceback (most recent call last):
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
jellyplex-watched  |     resp = conn.urlopen(
jellyplex-watched  |            ^^^^^^^^^^^^^
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 844, in urlopen
jellyplex-watched  |     retries = retries.increment(
jellyplex-watched  |               ^^^^^^^^^^^^^^^^^^
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/urllib3/util/retry.py", line 515, in increment
jellyplex-watched  |     raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
jellyplex-watched  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jellyplex-watched  | urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=32400): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f915e24be10>: Failed to establish a new connection: [Errno 111] Connection refused'))
jellyplex-watched  | 
jellyplex-watched  | During handling of the above exception, another exception occurred:
jellyplex-watched  | 
jellyplex-watched  | Traceback (most recent call last):
jellyplex-watched  |   File "/app/src/plex.py", line 427, in login
jellyplex-watched  |     plex = PlexServer(baseurl, token, session=self.session)
jellyplex-watched  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/plexapi/server.py", line 116, in __init__
jellyplex-watched  |     data = self.query(self.key, timeout=self._timeout)
jellyplex-watched  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/plexapi/server.py", line 759, in query
jellyplex-watched  |     response = method(url, headers=headers, timeout=timeout, **kwargs)
jellyplex-watched  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 602, in get
jellyplex-watched  |     return self.request("GET", url, **kwargs)
jellyplex-watched  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
jellyplex-watched  |     resp = self.send(prep, **send_kwargs)
jellyplex-watched  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
jellyplex-watched  |     r = adapter.send(request, **kwargs)
jellyplex-watched  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jellyplex-watched  |   File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 519, in send
jellyplex-watched  |     raise ConnectionError(e, request=request)
jellyplex-watched  | requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=32400): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f915e24be10>: Failed to establish a new connection: [Errno 111] Connection refused'))
jellyplex-watched  | 
jellyplex-watched  | During handling of the above exception, another exception occurred:
jellyplex-watched  | 
jellyplex-watched  | Traceback (most recent call last):
jellyplex-watched  |   File "/app/src/main.py", line 394, in main
jellyplex-watched  |     main_loop()
jellyplex-watched  |   File "/app/src/main.py", line 307, in main_loop
jellyplex-watched  |     servers = generate_server_connections()
jellyplex-watched  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jellyplex-watched  |   File "/app/src/main.py", line 88, in generate_server_connections
jellyplex-watched  |     server = Plex(
jellyplex-watched  |              ^^^^^
jellyplex-watched  |   File "/app/src/plex.py", line 420, in __init__
jellyplex-watched  |     self.plex = self.login(self.baseurl, self.token)
jellyplex-watched  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jellyplex-watched  |   File "/app/src/plex.py", line 442, in login
jellyplex-watched  |     raise Exception(e)
jellyplex-watched  | Exception: HTTPConnectionPool(host='localhost', port=32400): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f915e24be10>: Failed to establish a new connection: [Errno 111] Connection refused'))
jellyplex-watched  | 
jellyplex-watched  | Retrying in 3600.0

Type:

Additional context docker-compose.yml

services:
  jellyplex-watched:
    image: luigi311/jellyplex-watched:latest
    container_name: jellyplex-watched
    restart: always
    pull_policy: always
    volumes:
      - ./config:/config
    env_file:
      - .env

.env

# Global Settings

## Do not mark any shows/movies as played and instead just output to log if they would of been marked.
DRYRUN = "True"

## Additional logging information
DEBUG = "True"

## Debugging level, "info" is default, "debug" is more verbose
DEBUG_LEVEL = "info"

## If set to true then the script will only run once and then exit
RUN_ONLY_ONCE = "False"

## How often to run the script in seconds
SLEEP_DURATION = "3600"

## Log file where all output will be written to
LOGFILE = "log.log"

## Mark file where all shows/movies that have been marked as played will be written to
MARK_FILE = "mark.log" 

## Timeout for requests for jellyfin
REQUEST_TIMEOUT = 300

## Generate guids
## Generating guids is a slow process, so this is a way to speed up the process
## by using the location only, useful when using same files on multiple servers
GENERATE_GUIDS = "True"

## Generate locations
## Generating locations is a slow process, so this is a way to speed up the process
## by using the guid only, useful when using different files on multiple servers
GENERATE_LOCATIONS = "True"

## Max threads for processing
MAX_THREADS = 32

## Map usernames between servers in the event that they are different, order does not matter
## Comma separated for multiple options
#USER_MAPPING = { "rammjet": "rammjet" }

## Map libraries between servers in the event that they are different, order does not matter
## Comma separated for multiple options
#LIBRARY_MAPPING = { "TV Shows": "TV Shows" }

## Blacklisting/Whitelisting libraries, library types such as Movies/TV Shows, and users. Mappings apply so if the mapping for the user or library exist then both will be excluded.
## Comma separated for multiple options
#BLACKLIST_LIBRARY = ""
#WHITELIST_LIBRARY = ""
#BLACKLIST_LIBRARY_TYPE = ""
#WHITELIST_LIBRARY_TYPE = ""
#BLACKLIST_USERS = ""
WHITELIST_USERS = "rammjet"

# Plex

## Recommended to use token as it is faster to connect as it is direct to the server instead of going through the plex servers
## URL of the plex server, use hostname or IP address if the hostname is not resolving correctly
## Comma separated list for multiple servers
PLEX_BASEURL = "http://localhost:32400"

## Plex token https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
## Comma separated list for multiple servers
PLEX_TOKEN = "(generated token)"

## If not using plex token then use username and password of the server admin along with the servername
## Comma separated for multiple options
#PLEX_USERNAME = "PlexUser, PlexUser2"
#PLEX_PASSWORD = "SuperSecret, SuperSecret2"
#PLEX_SERVERNAME = "Plex Server1, Plex Server2"

## Skip hostname validation for ssl certificates.
## Set to True if running into ssl certificate errors
SSL_BYPASS = "True"

## control the direction of syncing. e.g. SYNC_FROM_PLEX_TO_JELLYFIN set to true will cause the updates from plex
## to be updated in jellyfin. SYNC_FROM_PLEX_TO_PLEX set to true will sync updates between multiple plex servers
SYNC_FROM_PLEX_TO_JELLYFIN = "True"
SYNC_FROM_JELLYFIN_TO_PLEX = "False"
SYNC_FROM_PLEX_TO_PLEX = "False"
SYNC_FROM_JELLYFIN_TO_JELLYFIN = "False"

# Jellyfin

## Jellyfin server URL, use hostname or IP address if the hostname is not resolving correctly
## Comma separated list for multiple servers
JELLYFIN_BASEURL = "http://localhost:8096"

## Jellyfin api token, created manually by logging in to the jellyfin server admin dashboard and creating an api key
## Comma separated list for multiple servers
JELLYFIN_TOKEN = "(generated api token)"
luigi311 commented 3 months ago

Looks like you are using http for plex baseurl, i had issues with that and had to use https even though it doesnt have a certificate. Can you try https://localhost:32400 instead

rammjet commented 3 months ago

Thanks. Same error with https. I previously had the environment variables inside the docker-compose.yml like your example and it had https in it. The error has led me to try a bunch of things.

I think I was using the wrong Plex token. I corrected that but have the same error.

rammjet commented 3 months ago

Changing "localhost" to the actual IP allowed login. But I had to do it for both Plex and Jellyfin.

A lot of [INFO] messages about not getting guids from Plex. Is this a problem?

luigi311 commented 3 months ago

ahh probably has to do with the ip of the docker compose network being different from whats running plex and jellyfin. I think some others ran into this issue too. If it fails to get guids that means that you dont have a match for the item so it will use file names only to create a match so if the files are the exact same across both servers it should be fine.

rammjet commented 3 months ago

It seems to be fine now. Thanks for the help. I'm closing this now.