linux-cli-community icon indicating copy to clipboard operation
linux-cli-community copied to clipboard

[BUG] API Error ProtonSessionAPIError: Timeout value connect was Timeout

Open xenithorb opened this issue 3 years ago • 2 comments

Describe the bug protonvpn-cli login <name> fails with error

Expected behavior After clean install, protonvpn-cli login should work without error

Error Messages/Program Output/Log Messages (~/.pvpn-cli/pvpn-cli.log)

Enter your ProtonVPN password: 
Attempting to login...

Unknown API error occured: ProtonSessionAPIError: Timeout value connect was Timeout(connect=10, read=30, total=None), but it must be an int, float or None.

Desktop (please complete the following information):

  • OS: Fedora 33
  • Python Version: Python 3.9.2
  • ProtonVPN-CLI Version: ProtonVPN CLI v3.3.1 (protonvpn-nm-lib v0.4.2; proton-client v0.3.0)

xenithorb avatar Mar 03 '21 03:03 xenithorb

Ah found the debug log:

2021-03-24 10:47:01,445 — cli_wrapper.py — INFO — CLIWrapper:41 — 
-------------------------------------------------

-----------	Initialized protonvpn-cli	-----------

-------------------------------------------------
2021-03-24 10:47:01,446 — cli.py — INFO — __init__:16 — ProtonVPN CLI v3.3.1 (protonvpn-nm-lib v0.4.2; proton-client v0.3.0)
2021-03-24 10:47:01,447 — cli.py — INFO — __init__:44 — CLI command: Namespace(command='login', version=False, help=False)
2021-03-24 10:47:01,448 — killswitch_manager.py — INFO — __init__:62 — Initialized killswitch manager
2021-03-24 10:47:01,450 — killswitch_manager.py — INFO — check_status_connectivity_check:492 — Conn check available (1) - Conn check enabled (1)
2021-03-24 10:47:01,450 — user_manager.py — INFO — __init__:28 — Initialized UserManager: service-> "ProtonVPN"; users-> "[SessionData, UserData, ProtonUser]"
2021-03-24 10:47:01,450 — user_session_manager.py — INFO — set_optimum_keyring_backend:219 — Setting optimum backend
2021-03-24 10:47:01,522 — user_session_manager.py — INFO — set_optimum_keyring_backend:269 — Keyring backend: ('SecretService', '5', <keyring.backends.SecretService.Keyring object at 0x7f8944cdbaf0>)
2021-03-24 10:47:01,523 — user_session_manager.py — INFO — __init__:35 — Current DE: "GNOME"
2021-03-24 10:47:01,523 — ipv6_leak_protection_manager.py — INFO — __init__:37 — Intialized IPv6 leak protection manager
2021-03-24 10:47:01,523 — cli_wrapper.py — INFO — login:179 — Checking for existing session
2021-03-24 10:47:01,523 — cli_wrapper.py — INFO — get_existing_session:799 — Attempt to get existing session
2021-03-24 10:47:01,523 — user_session_manager.py — INFO — load_stored_user_session:50 — Loading stored user session
2021-03-24 10:47:01,527 — user_session_manager.py — INFO — json_session_transform:206 — Transforming session: "load"
2021-03-24 10:47:01,528 — user_session_manager.py — ERROR — get_stored_data:159 — [!] JSONDataNoneError: the JSON object must be str, bytes or bytearray, not NoneType
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/protonvpn_nm_lib/services/user_session_manager.py", line 151, in get_stored_data
    return self.json_session_transform(
  File "/usr/lib/python3.9/site-packages/protonvpn_nm_lib/services/user_session_manager.py", line 212, in json_session_transform
    return json_action(session_data)
  File "/usr/lib64/python3.9/json/__init__.py", line 339, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
2021-03-24 10:47:01,529 — connection_manager.py — INFO — check_internet_connectivity:349 — Checking internet connectivity
2021-03-24 10:47:05,704 — cli_wrapper.py — INFO — login:192 — Asking for ProtonVPN credentials
2021-03-24 10:47:06,528 — cli_wrapper.py — INFO — login:197 — Credentials provided, attempting to login
2021-03-24 10:47:06,587 — proton_session_wrapper.py — INFO — setup_error_handling:478 — Setting up error handling
2021-03-24 10:47:06,588 — proton_session_wrapper.py — INFO — setup_exception_handling:514 — Setting up exception handling
2021-03-24 10:47:06,638 — proton_session_wrapper.py — INFO — authenticate:89 — Authenticating user
2021-03-24 10:47:06,638 — proton_session_wrapper.py — INFO — call_api_method:418 — Method: authenticate - <bound method Session.authenticate of <proton.api.Session object at 0x7f8944c26fd0>>
2021-03-24 10:47:06,640 — proton_session_wrapper.py — ERROR — call_api_method:435 — [!] ProtonSessionAPIError: Timeout value connect was Timeout(connect=10, read=30, total=None), but it must be an int, float or None.. Raising exception.
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/urllib3/util/timeout.py", line 132, in _validate_timeout
    float(value)
TypeError: float() argument must be a string or a number, not 'Timeout'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/protonvpn_nm_lib/services/proton_session_wrapper.py", line 425, in call_api_method
    api_response = self.api_methods[method](
  File "/usr/lib/python3.9/site-packages/proton/api.py", line 143, in authenticate
    info_response = self.api_request("/auth/info", payload)
  File "/usr/lib/python3.9/site-packages/proton/api.py", line 104, in api_request
    ret = fct(
  File "/home/xenith/.local/lib/python3.9/site-packages/requests/sessions.py", line 522, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/home/xenith/.local/lib/python3.9/site-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/xenith/.local/lib/python3.9/site-packages/requests/sessions.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "/home/xenith/.local/lib/python3.9/site-packages/requests/adapters.py", line 413, in send
    resp = conn.urlopen(
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 653, in urlopen
    timeout_obj = self._get_timeout(timeout)
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 324, in _get_timeout
    return Timeout.from_float(timeout)
  File "/usr/lib/python3.9/site-packages/urllib3/util/timeout.py", line 169, in from_float
    return Timeout(read=timeout, connect=timeout)
  File "/usr/lib/python3.9/site-packages/urllib3/util/timeout.py", line 96, in __init__
    self._connect = self._validate_timeout(connect, "connect")
  File "/usr/lib/python3.9/site-packages/urllib3/util/timeout.py", line 134, in _validate_timeout
    raise ValueError(
ValueError: Timeout value connect was Timeout(connect=10, read=30, total=None), but it must be an int, float or None.
2021-03-24 10:47:06,641 — cli_wrapper.py — ERROR — login_user:859 — [!] ProtonSessionWrapperError: ProtonSessionAPIError: Timeout value connect was Timeout(connect=10, read=30, total=None), but it must be an int, float or None.
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/urllib3/util/timeout.py", line 132, in _validate_timeout
    float(value)
TypeError: float() argument must be a string or a number, not 'Timeout'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/protonvpn_nm_lib/services/proton_session_wrapper.py", line 425, in call_api_method
    api_response = self.api_methods[method](
  File "/usr/lib/python3.9/site-packages/proton/api.py", line 143, in authenticate
    info_response = self.api_request("/auth/info", payload)
  File "/usr/lib/python3.9/site-packages/proton/api.py", line 104, in api_request
    ret = fct(
  File "/home/xenith/.local/lib/python3.9/site-packages/requests/sessions.py", line 522, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/home/xenith/.local/lib/python3.9/site-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/xenith/.local/lib/python3.9/site-packages/requests/sessions.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "/home/xenith/.local/lib/python3.9/site-packages/requests/adapters.py", line 413, in send
    resp = conn.urlopen(
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 653, in urlopen
    timeout_obj = self._get_timeout(timeout)
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 324, in _get_timeout
    return Timeout.from_float(timeout)
  File "/usr/lib/python3.9/site-packages/urllib3/util/timeout.py", line 169, in from_float
    return Timeout(read=timeout, connect=timeout)
  File "/usr/lib/python3.9/site-packages/urllib3/util/timeout.py", line 96, in __init__
    self._connect = self._validate_timeout(connect, "connect")
  File "/usr/lib/python3.9/site-packages/urllib3/util/timeout.py", line 134, in _validate_timeout
    raise ValueError(
ValueError: Timeout value connect was Timeout(connect=10, read=30, total=None), but it must be an int, float or None.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/protonvpn_cli/cli_wrapper.py", line 849, in login_user
    self.user_manager.login(protonvpn_username, protonvpn_password)
  File "/usr/lib/python3.9/site-packages/protonvpn_nm_lib/services/user_manager.py", line 55, in login
    session.authenticate(username, password)
  File "/usr/lib/python3.9/site-packages/protonvpn_nm_lib/services/proton_session_wrapper.py", line 90, in authenticate
    api_response, error = self.call_api_method(
  File "/usr/lib/python3.9/site-packages/protonvpn_nm_lib/services/proton_session_wrapper.py", line 438, in call_api_method
    raise exceptions.ProtonSessionAPIError(
protonvpn_nm_lib.exceptions.ProtonSessionAPIError: ProtonSessionAPIError: Timeout value connect was Timeout(connect=10, read=30, total=None), but it must be an int, float or None.

xenithorb avatar Mar 24 '21 14:03 xenithorb

Can you try using an older version of python, such as 3.8? Also, what are you requests and urllib3 versions? Somehow it seems requests is not happy with the tuple passed for timeout, even though that's normally how it is done.

A whacky thought, but looking at the code of the Proton CLI, maybe you could try going to /usr/lib/python3.9/site-packages/proton/constants.py and changing DEFAULT_TIMEOUT to None or 10. From my testing this shouldn't cause any errors, but I can't really test your issue as I can't reproduce the problem.

TauSigma5 avatar Mar 24 '21 18:03 TauSigma5