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

'protonvpn status' Fails with "IndexError: list index out of range"

Open westcoastsuccess opened this issue 4 years ago • 2 comments

Describe the bug

I was alerted by the online document I was working on that I'd lost my internet connection. My internet service seemed to be fine (phone on same network unaffected), so I attempted to see if ProtonVPN was the issue, and ran 'protonvpn status' (I run the ProtonVPN-CLI v2.2.4 on Linux Mint). It returned:

protonvpn status
Traceback (most recent call last):
  File "/usr/local/bin/protonvpn", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/protonvpn_cli/cli.py", line 73, in main
    cli()
  File "/usr/local/lib/python3.6/dist-packages/protonvpn_cli/cli.py", line 139, in cli
    connection.status()
  File "/usr/local/lib/python3.6/dist-packages/protonvpn_cli/connection.py", line 402, in status
    country_code = get_server_value(connected_server, "ExitCountry", servers)
  File "/usr/local/lib/python3.6/dist-packages/protonvpn_cli/utils.py", line 115, in get_server_value
    return value[0]
IndexError: list index out of range

I tried this repeatedly, with the same result, including when my computer came back online.

I eventually restarted ProtonVPN and got this, which seems to indicate the VPN was indeed running:

sudo protonvpn c -f
There is already a VPN connection running.
Terminating previous connection...
Connecting to CA#4 via UDP...
Connected!

Thereafter, the problem disappeared:

protonvpn status
Status:       Connected
Time:         0:00:04
IP:           104.254.92.62
Server:       CA#4
Features:     Normal
Protocol:     UDP
Kill Switch:  Disabled
Country:      Canada
City:         Toronto
Load:         43%
Received:     79.91 KB
Sent:         75.97 KB

My system is set up to automatically connect to ProtonVPN, so could perhaps the issue be in the reconnection attempt following a brief connection glitch with my ISP?

To Reproduce Steps to reproduce the behavior:

  1. At the command line, type:

protonvpn status 2. Get:

Traceback (most recent call last):
  File "/usr/local/bin/protonvpn", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/protonvpn_cli/cli.py", line 73, in main
    cli()
  File "/usr/local/lib/python3.6/dist-packages/protonvpn_cli/cli.py", line 139, in cli
    connection.status()
  File "/usr/local/lib/python3.6/dist-packages/protonvpn_cli/connection.py", line 402, in status
    country_code = get_server_value(connected_server, "ExitCountry", servers)
  File "/usr/local/lib/python3.6/dist-packages/protonvpn_cli/utils.py", line 115, in get_server_value
    return value[0]
IndexError: list index out of range
  1. Scratch head; look confused...

Expected behavior

Usually protonvpn status either returns connection information, or advises that ProtonVPN is disconnected.

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

Looks like ProtonVPN was repeatedly attempting to restart (none of these "NEW PROCESS STARTED" instances were initiated by me - I've pasted the log until it reaches my manual restart, not included here (or was my attempt to get the status causing the restarts?):

2020-06-21 13:50:15,004 — protonvpn-cli — DEBUG — cli:84 — ########################### 2020-06-21 13:50:15,005 — protonvpn-cli — DEBUG — cli:85 — ### NEW PROCESS STARTED ### 2020-06-21 13:50:15,005 — protonvpn-cli — DEBUG — cli:86 — ########################### 2020-06-21 13:50:15,005 — protonvpn-cli — DEBUG — cli:87 — ['/usr/local/bin/protonvpn', 'status'] 2020-06-21 13:50:15,005 — protonvpn-cli — DEBUG — cli:88 — USER: REMOVED 2020-06-21 13:50:15,005 — protonvpn-cli — DEBUG — cli:89 — CONFIG_DIR: /home/ REMOVED/.pvpn-cli 2020-06-21 13:50:15,008 — protonvpn-cli — DEBUG — cli:92 — Arguments {'--cc': None, '--fastest': False, '--help': False, '--p2p': False, '--random': False, '--sc': False, '--tor': False, '--version': False, '-p': None, '': None, 'c': False, 'configure': False, 'connect': False, 'd': False, 'disconnect': False, 'examples': False, 'init': False, 'r': False, 'reconnect': False, 'refresh': False, 's': False, 'status': True} 2020-06-21 13:50:15,010 — protonvpn-cli — DEBUG — status:358 — Getting VPN Status 2020-06-21 13:50:15,018 — protonvpn-cli — DEBUG — is_connected:197 — Checking connection Status. OpenVPN processes: 1 2020-06-21 13:50:15,018 — protonvpn-cli — DEBUG — call_api:36 — Initiating API Call: https://api.protonvpn.ch/vpn/logicals 2020-06-21 13:50:25,029 — protonvpn-cli — DEBUG — call_api:51 — Error connecting to ProtonVPN API 2020-06-21 13:50:44,347 — protonvpn-cli — DEBUG — cli:84 — ########################### 2020-06-21 13:50:44,348 — protonvpn-cli — DEBUG — cli:85 — ### NEW PROCESS STARTED ### 2020-06-21 13:50:44,348 — protonvpn-cli — DEBUG — cli:86 — ########################### 2020-06-21 13:50:44,348 — protonvpn-cli — DEBUG — cli:87 — ['/usr/local/bin/protonvpn', 'status'] 2020-06-21 13:50:44,348 — protonvpn-cli — DEBUG — cli:88 — USER: REMOVED 2020-06-21 13:50:44,348 — protonvpn-cli — DEBUG — cli:89 — CONFIG_DIR: /home/ REMOVED/.pvpn-cli 2020-06-21 13:50:44,354 — protonvpn-cli — DEBUG — cli:92 — Arguments {'--cc': None, '--fastest': False, '--help': False, '--p2p': False, '--random': False, '--sc': False, '--tor': False, '--version': False, '-p': None, '': None, 'c': False, 'configure': False, 'connect': False, 'd': False, 'disconnect': False, 'examples': False, 'init': False, 'r': False, 'reconnect': False, 'refresh': False, 's': False, 'status': True} 2020-06-21 13:50:44,359 — protonvpn-cli — DEBUG — status:358 — Getting VPN Status 2020-06-21 13:50:44,368 — protonvpn-cli — DEBUG — is_connected:197 — Checking connection Status. OpenVPN processes: 1 2020-06-21 13:50:44,370 — protonvpn-cli — DEBUG — call_api:36 — Initiating API Call: https://api.protonvpn.ch/vpn/logicals 2020-06-21 13:50:45,968 — protonvpn-cli — DEBUG — call_api:65 — Successful json response 2020-06-21 13:50:46,001 — protonvpn-cli — DEBUG — pull_server_data:87 — SERVER_INFO_FILE written 2020-06-21 13:50:46,008 — protonvpn-cli — DEBUG — pull_server_data:94 — last_api_call updated 2020-06-21 13:50:46,016 — protonvpn-cli — DEBUG — get_servers:101 — Reading servers from file 2020-06-21 13:50:46,022 — protonvpn-cli — DEBUG — get_ip_info:143 — Getting IP Information 2020-06-21 13:50:46,022 — protonvpn-cli — DEBUG — call_api:36 — Initiating API Call: https://api.protonvpn.ch/vpn/location 2020-06-21 13:50:46,396 — protonvpn-cli — DEBUG — call_api:65 — Successful json response 2020-06-21 13:50:46,397 — protonvpn-cli — DEBUG — status:401 — Collecting status information 2020-06-21 13:50:56,902 — protonvpn-cli — DEBUG — cli:84 — ########################### 2020-06-21 13:50:56,902 — protonvpn-cli — DEBUG — cli:85 — ### NEW PROCESS STARTED ### 2020-06-21 13:50:56,902 — protonvpn-cli — DEBUG — cli:86 — ########################### 2020-06-21 13:50:56,902 — protonvpn-cli — DEBUG — cli:87 — ['/usr/local/bin/protonvpn', 'status'] 2020-06-21 13:50:56,902 — protonvpn-cli — DEBUG — cli:88 — USER: REMOVED 2020-06-21 13:50:56,902 — protonvpn-cli — DEBUG — cli:89 — CONFIG_DIR: /home/ REMOVED/.pvpn-cli 2020-06-21 13:50:56,905 — protonvpn-cli — DEBUG — cli:92 — Arguments {'--cc': None, '--fastest': False, '--help': False, '--p2p': False, '--random': False, '--sc': False, '--tor': False, '--version': False, '-p': None, '': None, 'c': False, 'configure': False, 'connect': False, 'd': False, 'disconnect': False, 'examples': False, 'init': False, 'r': False, 'reconnect': False, 'refresh': False, 's': False, 'status': True} 2020-06-21 13:50:56,907 — protonvpn-cli — DEBUG — status:358 — Getting VPN Status 2020-06-21 13:50:56,915 — protonvpn-cli — DEBUG — is_connected:197 — Checking connection Status. OpenVPN processes: 1 2020-06-21 13:50:56,915 — protonvpn-cli — DEBUG — pull_server_data:80 — Last server pull within 15mins 2020-06-21 13:50:56,921 — protonvpn-cli — DEBUG — get_servers:101 — Reading servers from file 2020-06-21 13:50:56,926 — protonvpn-cli — DEBUG — get_ip_info:143 — Getting IP Information 2020-06-21 13:50:56,926 — protonvpn-cli — DEBUG — call_api:36 — Initiating API Call: https://api.protonvpn.ch/vpn/location 2020-06-21 13:50:57,324 — protonvpn-cli — DEBUG — call_api:65 — Successful json response 2020-06-21 13:50:57,325 — protonvpn-cli — DEBUG — status:401 — Collecting status information 2020-06-21 13:52:08,266 — protonvpn-cli — DEBUG — cli:84 — ########################### 2020-06-21 13:52:08,266 — protonvpn-cli — DEBUG — cli:85 — ### NEW PROCESS STARTED ### 2020-06-21 13:52:08,266 — protonvpn-cli — DEBUG — cli:86 — ########################### 2020-06-21 13:52:08,266 — protonvpn-cli — DEBUG — cli:87 — ['/usr/local/bin/protonvpn', '--version'] 2020-06-21 13:52:08,266 — protonvpn-cli — DEBUG — cli:88 — USER: REMOVED 2020-06-21 13:52:08,266 — protonvpn-cli — DEBUG — cli:89 — CONFIG_DIR: /home/ REMOVED/.pvpn-cli 2020-06-21 13:53:08,506 — protonvpn-cli — DEBUG — cli:84 — ########################### 2020-06-21 13:53:08,506 — protonvpn-cli — DEBUG — cli:85 — ### NEW PROCESS STARTED ### 2020-06-21 13:53:08,506 — protonvpn-cli — DEBUG — cli:86 — ########################### 2020-06-21 13:53:08,506 — protonvpn-cli — DEBUG — cli:87 — ['/usr/local/bin/protonvpn', 'status'] 2020-06-21 13:53:08,506 — protonvpn-cli — DEBUG — cli:88 — USER: REMOVED 2020-06-21 13:53:08,506 — protonvpn-cli — DEBUG — cli:89 — CONFIG_DIR: /home/ REMOVED/.pvpn-cli 2020-06-21 13:53:08,509 — protonvpn-cli — DEBUG — cli:92 — Arguments {'--cc': None, '--fastest': False, '--help': False, '--p2p': False, '--random': False, '--sc': False, '--tor': False, '--version': False, '-p': None, '': None, 'c': False, 'configure': False, 'connect': False, 'd': False, 'disconnect': False, 'examples': False, 'init': False, 'r': False, 'reconnect': False, 'refresh': False, 's': False, 'status': True} 2020-06-21 13:53:08,511 — protonvpn-cli — DEBUG — status:358 — Getting VPN Status 2020-06-21 13:53:08,519 — protonvpn-cli — DEBUG — is_connected:197 — Checking connection Status. OpenVPN processes: 1 2020-06-21 13:53:08,519 — protonvpn-cli — DEBUG — pull_server_data:80 — Last server pull within 15mins 2020-06-21 13:53:08,527 — protonvpn-cli — DEBUG — get_servers:101 — Reading servers from file 2020-06-21 13:53:08,533 — protonvpn-cli — DEBUG — get_ip_info:143 — Getting IP Information 2020-06-21 13:53:08,533 — protonvpn-cli — DEBUG — call_api:36 — Initiating API Call: https://api.protonvpn.ch/vpn/location 2020-06-21 13:53:08,983 — protonvpn-cli — DEBUG — call_api:65 — Successful json response 2020-06-21 13:53:08,984 — protonvpn-cli — DEBUG — status:401 — Collecting status information 2020-06-21 13:55:36,382 — protonvpn-cli — DEBUG — cli:84 — ########################### 2020-06-21 13:55:36,383 — protonvpn-cli — DEBUG — cli:85 — ### NEW PROCESS STARTED ### 2020-06-21 13:55:36,383 — protonvpn-cli — DEBUG — cli:86 — ########################### 2020-06-21 13:55:36,383 — protonvpn-cli — DEBUG — cli:87 — ['/usr/local/bin/protonvpn', 'status'] 2020-06-21 13:55:36,383 — protonvpn-cli — DEBUG — cli:88 — USER: REMOVED 2020-06-21 13:55:36,383 — protonvpn-cli — DEBUG — cli:89 — CONFIG_DIR: /home/ REMOVED/.pvpn-cli 2020-06-21 13:55:36,385 — protonvpn-cli — DEBUG — cli:92 — Arguments {'--cc': None, '--fastest': False, '--help': False, '--p2p': False, '--random': False, '--sc': False, '--tor': False, '--version': False, '-p': None, '': None, 'c': False, 'configure': False, 'connect': False, 'd': False, 'disconnect': False, 'examples': False, 'init': False, 'r': False, 'reconnect': False, 'refresh': False, 's': False, 'status': True} 2020-06-21 13:55:36,387 — protonvpn-cli — DEBUG — status:358 — Getting VPN Status 2020-06-21 13:55:36,395 — protonvpn-cli — DEBUG — is_connected:197 — Checking connection Status. OpenVPN processes: 1 2020-06-21 13:55:36,395 — protonvpn-cli — DEBUG — pull_server_data:80 — Last server pull within 15mins 2020-06-21 13:55:36,401 — protonvpn-cli — DEBUG — get_servers:101 — Reading servers from file 2020-06-21 13:55:36,407 — protonvpn-cli — DEBUG — get_ip_info:143 — Getting IP Information 2020-06-21 13:55:36,408 — protonvpn-cli — DEBUG — call_api:36 — Initiating API Call: https://api.protonvpn.ch/vpn/location 2020-06-21 13:55:37,498 — protonvpn-cli — DEBUG — call_api:65 — Successful json response 2020-06-21 13:55:37,499 — protonvpn-cli — DEBUG — status:401 — Collecting status information 2020-06-21 14:00:47,914 — protonvpn-cli — DEBUG — cli:84 — ########################### 2020-06-21 14:00:47,914 — protonvpn-cli — DEBUG — cli:85 — ### NEW PROCESS STARTED ### 2020-06-21 14:00:47,914 — protonvpn-cli — DEBUG — cli:86 — ########################### 2020-06-21 14:00:47,914 — protonvpn-cli — DEBUG — cli:87 — ['/usr/local/bin/protonvpn', '-cf'] 2020-06-21 14:00:47,914 — protonvpn-cli — DEBUG — cli:88 — USER: REMOVED 2020-06-21 14:00:47,914 — protonvpn-cli — DEBUG — cli:89 — CONFIG_DIR: /home/ REMOVED/.pvpn-cli

Desktop (please complete the following information):

  • OS: Linux Mint 19.2
  • Python Version: Python 3.6.9
  • ProtonVPN-CLI Version: ProtonVPN-CLI v2.2.4

Additional context This isn't a big issue - just making you aware in case it points to more significant issues. I've been using ProtonVPN for maybe 9 months - love it! - and this is a new development.

I'm a fairly unsophisticated user, but happy to help troubleshoot further, if needed.

westcoastsuccess avatar Jun 21 '20 18:06 westcoastsuccess

none of these "NEW PROCESS STARTED" instances were initiated by m

The CLI has no background process, so this likely is caused by systemd. I can also imagine it has something to do with that service why you're encountering the error.

Rafficer avatar Jun 21 '20 18:06 Rafficer

Thanks for responding. Probably it was a one-off, and I'm not too worried about it if you aren't.

I can't for the life of me recall how I set up ProtonVPN to autoconnect - I tried to find the instructions but can't. In any case, there is a file called 'protonvpn-autoconnect.service' that looks like this:

[Unit]
Description=ProtonVPN-CLI auto-connect
Wants=network-online.target

[Service]
Type=forking
ExecStart=/usr/local/bin/protonvpn connect -f
Environment=PVPN_WAIT=300
Environment=PVPN_DEBUG=1
Environment=SUDO_USER=**REMOVED**

[Install]
WantedBy=multi-user.target

westcoastsuccess avatar Jun 21 '20 20:06 westcoastsuccess