fuzeman / trakt-tools

Command-line tools for Trakt.tv.
37 stars 5 forks source link

SSL error trying to access Trakt API #9

Closed outdooracorn closed 1 year ago

outdooracorn commented 1 year ago

Python version: 3.10.8 trakt-tools version: 0.2.1 OS: ManjaroLinux 22.0.0

Command executed: run.py --rate-limit 10 history:duplicates:merge --no-backup --review --delta-max 3600 --token <redacted>

Command with output ```console $ /home/ollie/git/github/outdooracorn/trakt-tools/.venv/bin/python /home/ollie/git/github/outdooracorn/trakt-tools/run.py --rate-limit 10 history:duplicates:merge --no-backup --review --delta-max 3600 --token d254ae4cf163adf05e14be4f3a37bb71e2446c702d850985adde466e4e306651 Requesting profile... WARNING:urllib3.connectionpool:Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL] internal error (_ssl.c:997)'))': /users/settings WARNING:urllib3.connectionpool:Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL] internal error (_ssl.c:997)'))': /users/settings WARNING:urllib3.connectionpool:Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL] internal error (_ssl.c:997)'))': /users/settings Traceback (most recent call last): File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen httplib_response = self._make_request( File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 386, in _make_request self._validate_conn(conn) File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn conn.connect() File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/urllib3/connection.py", line 414, in connect self.sock = ssl_wrap_socket( File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket ssl_sock = _ssl_wrap_socket_impl( File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock, server_hostname=server_hostname) File "/usr/lib/python3.10/ssl.py", line 513, in wrap_socket return self.sslsocket_class._create( File "/usr/lib/python3.10/ssl.py", line 1071, in _create self.do_handshake() File "/usr/lib/python3.10/ssl.py", line 1342, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL] internal error (_ssl.c:997) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/requests/adapters.py", line 489, in send resp = conn.urlopen( File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 815, in urlopen return self.urlopen( File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 815, in urlopen return self.urlopen( File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 815, in urlopen return self.urlopen( File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen retries = retries.increment( File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api-v2launch.trakt.tv', port=443): Max retries exceeded with url: /users/settings (Caused by SSLError(SSLError(1, '[SSL] internal error (_ssl.c:997)'))) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/ollie/git/github/outdooracorn/trakt-tools/run.py", line 5, in main() File "/home/ollie/git/github/outdooracorn/trakt-tools/trakt_tools/runner/main.py", line 59, in main cli(prog_name=get_prog(), obj={}, max_content_width=100) File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/click/core.py", line 722, in __call__ return self.main(*args, **kwargs) File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/click/core.py", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/click/core.py", line 535, in invoke return callback(*args, **kwargs) File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/home/ollie/git/github/outdooracorn/trakt-tools/trakt_tools/runner/commands/history/duplicates/merge.py", line 63, in history_duplicates_merge success = MergeHistoryDuplicatesTask( File "/home/ollie/git/github/outdooracorn/trakt-tools/trakt_tools/tasks/history/duplicates/merge/main.py", line 34, in run return self.process( File "/home/ollie/git/github/outdooracorn/trakt-tools/trakt_tools/tasks/history/duplicates/merge/main.py", line 44, in process profile = Profile.fetch( File "/home/ollie/git/github/outdooracorn/trakt-tools/trakt_tools/models/profile.py", line 266, in fetch settings = Trakt['users/settings'].get() File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/trakt/interfaces/users/settings.py", line 8, in get response = self.http.get() File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/trakt/core/http.py", line 126, in get return self.request('GET', path, params, data, **kwargs) File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/trakt/core/http.py", line 84, in request return self.send(prepared) File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/trakt/core/http.py", line 102, in send response = self.session.send(request, timeout=timeout) File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/requests/sessions.py", line 701, in send r = adapter.send(request, **kwargs) File "/home/ollie/git/github/outdooracorn/trakt-tools/.venv/lib/python3.10/site-packages/requests/adapters.py", line 563, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='api-v2launch.trakt.tv', port=443): Max retries exceeded with url: /users/settings (Caused by SSLError(SSLError(1, '[SSL] internal error (_ssl.c:997)'))) ```

Looks like an issue with the TLS version used: https://stackoverflow.com/a/71059579.

I noticed requests are handled by trakt.py which is pinned at version 2.8. Updating this dependency should fix it.