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

add_to_collection : Plex ReadTimeout #1455

Closed
3 tasks done
steve1977 opened this issue Apr 16, 2023 · 40 comments
Closed
3 tasks done

add_to_collection : Plex ReadTimeout #1455

steve1977 opened this issue Apr 16, 2023 · 40 comments
Labels
bug Something isn't working

Comments

@steve1977
Copy link

steve1977 commented Apr 16, 2023

Confirmation

  • I have read the README.md on the project homepage
  • I have checked if identical issue already exists
  • I have tried downgrading to find version that can be used as a workaround

The problem

Subject says it all. It syncs well for a few hundred movies, but then just stops. Error log below.

Error trace / logs

File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/app/plextraktsync/__main__.py", line 18, in <module>
    cli()
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1635, in invoke
    rv = super().invoke(ctx)
         ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/plextraktsync/cli.py", line 69, in cli
    sync()
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/plextraktsync/cli.py", line 25, in wrap
    cmd(*args, **kwargs)
  File "/app/plextraktsync/commands/sync.py", line 68, in sync
    runner.sync(walker=w, dry_run=config.dry_run)
  File "/app/plextraktsync/sync.py", line 66, in sync
    self.sync_collection(movie, dry_run=dry_run)
  File "/app/plextraktsync/sync.py", line 127, in sync_collection
    m.add_to_collection()
  File "/app/plextraktsync/media.py", line 127, in add_to_collection
    self.trakt_api.add_to_collection(self.trakt, self.plex)
  File "/app/plextraktsync/trakt/TraktApi.py", line 182, in add_to_collection
    **pm.to_json(),
      ^^^^^^^^^^^^
  File "/app/plextraktsync/plex/PlexLibraryItem.py", line 325, in to_json
    "resolution": self.resolution,
                  ^^^^^^^^^^^^^^^
  File "/app/plextraktsync/plex/PlexLibraryItem.py", line 209, in resolution
    stream = self.video_streams[0]
             ^^^^^^^^^^^^^^^^^^
  File "/app/plextraktsync/plex/PlexLibraryItem.py", line 161, in video_streams
    return self.item.videoStreams()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plexapi/video.py", line 105, in videoStreams
    self.reload()
  File "/usr/local/lib/python3.11/site-packages/plexapi/base.py", line 368, in reload
    return self._reload(key=key, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plexapi/base.py", line 377, in _reload
    data = self._server.query(key)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plexapi/server.py", line 745, in query
    response = method(url, headers=headers, timeout=timeout, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests_cache/session.py", line 103, in get
    return self.request('GET', url, params=params, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests_cache/session.py", line 159, in request
    return super().request(method, url, *args, headers=headers, **kwargs)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests_cache/session.py", line 206, in send
    response = self._send_and_cache(request, actions, cached_response, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests_cache/session.py", line 230, in _send_and_cache
    response = super().send(request, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 578, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='192.168.11.120', port=32400): Read timed out. (read timeout=30)

Expected behavior

Finish the sync

Steps to reproduce the behavior

Restarted a few times. Re-run. Same prob happens every time

Inspect of problematic items

No response

Workarounds

No response

Install method

docker-compose

Config file contents

No response

Version

0.25.17

Python Version

Don't know

Operating System and Version

Unraid docker container

@simonc56
Copy link
Collaborator

Duplicate of #956

add_to_collection() requires item resolution and it fails to reload Plex item to get the video_streams

@simonc56 simonc56 changed the title Sync does not complete add_to_collection : Plex ReadTimeout Apr 16, 2023
@simonc56
Copy link
Collaborator

@steve1977 can you try to disable collection :

sync:
  plex_to_trakt:
    collection: false

@glensc
Copy link
Collaborator

glensc commented Apr 16, 2023

or set bigger plex timeout:

plex:
  timeout: 300

is the crash every time the same item? progressbar number could indicate that.

@steve1977
Copy link
Author

@steve1977 can you try to disable collection :

sync:
  plex_to_trakt:
    collection: false

This works in the way that it runs through and completes the sync.

However, the sync doesn't seem to work. Not all my Plex movies are marked as "collected" in Trakt. Not sure how to best troubleshoot what is working / not working. Any suggestions?

@simonc56
Copy link
Collaborator

Not all my Plex movies are marked as "collected" in Trakt.

Of course, is was just for the test. We're trying to narrow down the problem. Seems to be related to collection.

Enable debug, run a sync, then read the lines before the crash to find the problematic movie and inspect it.

@simonc56 simonc56 added the bug Something isn't working label Apr 17, 2023
@steve1977
Copy link
Author

steve1977 commented Apr 18, 2023

I changed collection back to true and also set debug log to true. Unfortunately, now it doesn't work anymore. Log below:

2023-04-18 23:31:56,350 DEBUG[trakt.core]:RESPONSE [get] (https://api-v2launch.trakt.tv/users/likes/lists?limit=1000): <Response [200]>
2023-04-18 23:31:56,351 DEBUG[trakt.core]:get: https://api-v2launch.trakt.tv/lists/6167922
2023-04-18 23:31:56,351 DEBUG[trakt.core]:method, url :: get, https://api-v2launch.trakt.tv/lists/6167922
2023-04-18 23:31:56,353 DEBUG[requests_cache.policy.actions]:Cache directives from request headers: CacheDirectives()
2023-04-18 23:31:56,354 DEBUG[requests_cache.policy.actions]:Pre-read cache checks: Passed
2023-04-18 23:31:56,362 DEBUG[requests_cache.policy.actions]:Post-read cache actions: CacheActions(expire_after=-1)
2023-04-18 23:31:56,363 DEBUG[trakt.core]:RESPONSE [get] (https://api-v2launch.trakt.tv/lists/6167922): <CachedResponse [200]: created: 2023-01-26 12:39:23 CST, expires: N/A (fresh), size: 437 bytes, request: GET https://api-v2launch.trakt.tv/lists/6167922>
2023-04-18 23:31:56,364 ERROR[PlexTraktSync]:UserList.__new__() missing 1 required positional argument: 'share_link'
Traceback (most recent call last):
  File "/app/plextraktsync/cli.py", line 25, in wrap
    cmd(*args, **kwargs)
  File "/app/plextraktsync/commands/sync.py", line 68, in sync
    runner.sync(walker=w, dry_run=config.dry_run)
  File "/app/plextraktsync/sync.py", line 61, in sync
    listutil.addList(lst["listid"], lst["listname"])
  File "/app/plextraktsync/trakt_list_util.py", line 95, in addList
    self.lists.append(TraktList(listid, listname))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/plextraktsync/trakt_list_util.py", line 40, in __init__
    userlist = LazyUserList._get(listname, listid)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/trakt/core.py", line 558, in inner
    return generator.send(json_data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/plextraktsync/trakt_list_util.py", line 29, in _get
    ulist = cls(creator=data['user']['username'], **data)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: UserList.__new__() missing 1 required positional argument: 'share_link'

@glensc
Copy link
Collaborator

glensc commented Apr 18, 2023

@glensc
Copy link
Collaborator

glensc commented Apr 18, 2023

@simonc56
Copy link
Collaborator

simonc56 commented Apr 18, 2023

now it doesn't work anymore

remove cache, update to 0.26.1 and try again

And you ask suggestions but you didn't even answer to #1455 (comment)...

@steve1977
Copy link
Author

I had changed the timeout from 30 to 300, but it didn't seem to work. In the log, it still seems to apply 30 timeout although the config files reflects my change to 30.

Deleting the cache makes it run again, but it still gets stuck and stops after a few movies. Let me attach an updated log that may help troubleshooting. Thanks for your help!

https://pastebin.com/miV4XJe0

@simonc56
Copy link
Collaborator

adamus1red#1

@simonc56
Copy link
Collaborator

Can you show output of:
plextraktsync inspect 1042314

@steve1977
Copy link
Author

Here we go: https://pastebin.com/f368jp2S

@simonc56

This comment was marked as outdated.

@steve1977

This comment was marked as outdated.

@simonc56

This comment was marked as outdated.

@glensc
Copy link
Collaborator

glensc commented Apr 25, 2023

@steve1977
Copy link
Author

Sorry, I had been on holidays.

Unfortunately, I still cannot finish the sync. Updated debug log is attached.

https://pastebin.com/xy9YZC4v

I didn't ignore, but not sure how I select the code blocks in pastebin?

@glensc
Copy link
Collaborator

glensc commented May 6, 2023

  1. unclear what is in that paste? what version? what is config?
  2. you select Edit to your post (three dots of your comment) and do as written in the documentation: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#fenced-code-blocks

@steve1977
Copy link
Author

PlexTraktSync [0.26.4]
Config: https://pastebin.com/XhZ4DVV0

I'll try to make the edit above.

@glensc
Copy link
Collaborator

glensc commented Jul 31, 2023

paste expired. post to github instead of third party site. (it accepts .txt extension files. just drag them to text area)

Try to update to last version 0.26.10 and set plex timeout to 300, then give full log.

@steve1977
Copy link
Author

plextraktsync.log

Thanks. Deleted the cache and updated the docker container. Unfortunately, it seems not to connect. I think I need to wipe some more cache somewhere?

@codevski
Copy link

codevski commented Aug 18, 2023

keeping an eye out on this, seems like having add_collection false it works fine but times out when having it on true... Happy to also share the logs from the last adding to collection... config also has it set to 300

logs.txt

Edit: What I noticed is that if I manually add the collection of the failed episode it continues, unfortunately it does find another to fail on hrmmm

@steve1977
Copy link
Author

I wiped the contgainer and reinstalled. Increased timeout to 300. Unfortunately, still not working. Log attached.
[2023-08-19 195555,680 INFOPlexTrak.txt

@glensc
Copy link
Collaborator

glensc commented Aug 23, 2023

The log shows your timeout is still 30s:

requests.exceptions.ReadTimeout: HTTPConnectionPool(host='192.168.11.120', port=32400): Read timed out. (read timeout=30)

Refer to python-plex documentation how to change defaults, if plextraktsync config is not working:

@glensc
Copy link
Collaborator

glensc commented Aug 23, 2023

@glensc
Copy link
Collaborator

glensc commented Aug 23, 2023

Actually, we patch the global TIMEOUT:

so, it should have worked...

@steve1977
Copy link
Author

I double-checked and yet again made sure the timeout has been set to 300. I re-ran and it still errors our and says timeout is 30. See below. What else can I provide to trouble-shoot?

ReadTimeout: HTTPConnectionPool(host='192.168.11.120', port=32400): Read timed out. (read timeout=30)
Error: Error running sync command: HTTPConnectionPool(host='192.168.11.120', port=32400): Read timed out. (read timeout=30)

@glensc
Copy link
Collaborator

glensc commented Aug 28, 2023

I already wrote how:

or modify plexapi __init.py__ manualy

@cenunix
Copy link

cenunix commented Aug 29, 2023

hey @glensc how can i get around this when using docker? it doesnt seem to read .config/plexapi even when passing the environment variable for PLEXAPI_CONFIG_PATH in the docker-compose file. Any help would be appreciated, thanks

@cenunix
Copy link

cenunix commented Aug 29, 2023

update, this inside my docker compose seems to have done the trick

environment:
      - PLEXAPI_PLEXAPI_TIMEOUT=300

@glensc
Copy link
Collaborator

glensc commented Aug 30, 2023

Since workaround is found, closing.

@glensc glensc closed this as completed Aug 30, 2023
@steve1977
Copy link
Author

It still does not work for me as I am using Unraid docker (as many of us), where the work-around does not apply :-( Docker compose cannot be edited.

@cenunix
Copy link

cenunix commented Aug 31, 2023

It still does not work for me as I am using Unraid docker (as many of us), where the work-around does not apply :-( Docker compose cannot be edited.

I'm unfamiliar with unraid, @glensc submitted a fix for the configuration issue regarding the timeout value. Not sure when that will be usable but that should solve the issue for you.

@glensc
Copy link
Collaborator

glensc commented Aug 31, 2023

@cenunix workaround is to add env variable. I'm sure you can still do the same for Unraid

@glensc
Copy link
Collaborator

glensc commented Aug 31, 2023

plexapi fix merged to this repo:

@glensc
Copy link
Collaborator

glensc commented Aug 31, 2023

it's included in 0.27.1 release

@glensc
Copy link
Collaborator

glensc commented Aug 31, 2023

And in any case:

HTTPConnectionPool(host='192.168.11.120', port=32400): Read timed out.

is error from plex server. check plex media server logs.

@steve1977
Copy link
Author

Very cool, working now, thanks for the fix!

@danielsteiner
Copy link

danielsteiner commented Nov 29, 2023

update, this inside my docker compose seems to have done the trick

environment:
      - PLEXAPI_PLEXAPI_TIMEOUT=300

Neither this nor setting the timeout to 300 in my config.yml had any effect, in both cases, the timeout occurs after 30 seconds when I am syncing my collection.

Only syncing the watched items seems to work.

Edit: Nevermind. After I synced the watch state, collections started to work again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants