JohnDoee / autotorrent2

Cross-seed matching and torrent lifecycle tool
https://johndoee.github.io/autotorrent2/
MIT License
142 stars 10 forks source link

The handshake/read operation timed out #42

Open Jerrk opened 1 year ago

Jerrk commented 1 year ago

I've started running into an issue lately where trying to scan-client on deluge will time out after about 10 minutes.

Its running against over 6k torrents so there might be short hangups now and then but it seems at2 will time out the connection and break the scan.

heres the verbose error log

DEBUG:deluge_client.client:152:Calling reqid 6 method 'core.get_torrents_status' with args:({'id': ['xxx']}, ['name', 'files', 'file_progress']) kwargs:{}
INFO:deluge_client.client:96:Connecting to 10.10.10.10:58846
Traceback (most recent call last):
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/libtc/clients/deluge.py", line 185, in get_download_path
    with self.client as client:
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/deluge_client/client.py", line 273, in __enter__
    self.connect()
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/deluge_client/client.py", line 84, in connect
    self._connect()
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/deluge_client/client.py", line 98, in _connect
    self._socket.connect((self.host, self.port))
  File "/usr/lib64/python3.9/ssl.py", line 1342, in connect
    self._real_connect(addr, False)
  File "/usr/lib64/python3.9/ssl.py", line 1333, in _real_connect
    self.do_handshake()
  File "/usr/lib64/python3.9/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
socket.timeout: _ssl.c:1112: The handshake operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/user/appdata/autotorrent2/bin/at2", line 8, in <module>
    sys.exit(cli())
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/autotorrent/__main__.py", line 760, in scan_clients
    indexer.scan_clients(clients, full_scan=full, fast_scan=fast)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/autotorrent/indexer.py", line 116, in scan_clients
    self._scan_client(name, client, not full_scan and fast_scan)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/autotorrent/indexer.py", line 132, in _scan_client
    download_path = client.get_download_path(torrent.infohash)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/libtc/clients/deluge.py", line 191, in get_download_path
    raise FailedToExecuteException(
libtc.exceptions.FailedToExecuteException: Failed to fetch download_location from Deluge

Appears to just need a bit better error handling to skip the entry that it timed out on, increase the timeout timer, and/or retry the entry.

Jerrk commented 1 year ago

also getting "the read operation timed out"

Traceback (most recent call last):
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/libtc/clients/deluge.py", line 227, in get_files
    with self.client as client:
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/deluge_client/client.py", line 273, in __enter__
    self.connect()
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/deluge_client/client.py", line 86, in connect
    self._detect_deluge_version()
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/deluge_client/client.py", line 125, in _detect_deluge_version
    result = self._socket.recv(1)
  File "/usr/lib64/python3.9/ssl.py", line 1226, in recv
    return self.read(buflen)
  File "/usr/lib64/python3.9/ssl.py", line 1101, in read
    return self._sslobj.read(len)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/user/appdata/autotorrent2/bin/at2", line 8, in <module>
    sys.exit(cli())
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/autotorrent/__main__.py", line 760, in scan_clients
    indexer.scan_clients(clients, full_scan=full, fast_scan=fast)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/autotorrent/indexer.py", line 116, in scan_clients
    self._scan_client(name, client, not full_scan and fast_scan)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/autotorrent/indexer.py", line 139, in _scan_client
    files = client.get_files(torrent.infohash)
  File "/mnt/user/appdata/autotorrent2/lib64/python3.9/site-packages/libtc/clients/deluge.py", line 233, in get_files
    raise FailedToExecuteException("Failed to fetch files from Deluge")
libtc.exceptions.FailedToExecuteException: Failed to fetch files from Deluge
KyleSanderson commented 1 year ago

Very similar thing on qBittorrent.

JohnDoee commented 5 months ago

My guess is that the client is working too hard which makes the API too slow. The only solution is to make autotorrent wait longer.

Not sure if that just puts more work on the torrent client or what. Not really sure what the solution is here.