wakatime / legacy-python-cli

Command line interface used by all WakaTime text editor plugins.
https://wakatime.com/
BSD 3-Clause "New" or "Revised" License
1.02k stars 84 forks source link

VS Code connection error #191

Open just-Bri opened 4 years ago

just-Bri commented 4 years ago

[WakaTime][ERROR] ConnectionError: HTTPSConnectionPool(host='api.wakatime.com', port=443): Max retries exceeded with url: /api/v1/users/current/summaries?start=today&end=today (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x000001BE1AC56EB8>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',)) This is from the VS Code dev tools console.

just-Bri commented 4 years ago

Just to add, I have confirmed my API key is correct and tried reinstalling wakatime and VS Code.

phonnz commented 4 years ago

Unfortunately I have the same error for terminal and Code with: Version: 2.2.1 CLI Version: 13.0.1

Alo, in VSCode error console I get this: Error: tunneling socket could not be established, cause=connect ECONNREFUSED 127.0.0.1:8080

Some advice?

alanhamlett commented 4 years ago

The 127.0.0.1:8080 isn't a WakaTime server so that error probably isn't related to WakaTime. @phonnz and @reifnotreef, can you check if:

  1. Does today's coding time show in your VS Code status bar?

  2. Does this error occur constantly, or only sometimes?

phonnz commented 4 years ago

Seems like some problem with python. I uninstalled wakatime plugin from pip for terminal, and cloned the repo, and reinstalled with pip, and I get this error

{"now": "2019/12/03 03:33:31 +0000", "version": "13.0.2", "plugin": "wakatime-zsh-plugin/0.2.1", "time": 1575365611.010461, "caller": "/home/phonnz/.local/lib/python2.7/site-packages/wakatime/api.py", "lineno": 125, "is_write": true, "file": "npm", "level": "WARNING", "message": "{'ProxyError': u\"HTTPSConnectionPool(host='api.wakatime.com', port=443): Max retries exceeded with url: /api/v1/users/current/heartbeats.bulk (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ffb39a33ed0>: Failed to establish a new connection: [Errno 111] Connection refused',)))\", 'traceback': 'Traceback (most recent call last):\n File \"/home/phonnz/.local/lib/python2.7/site-packages/wakatime/api.py\", line 111, in send_heartbeats\n verify=ssl_verify)\n File \"/home/phonnz/.local/lib/python2.7/site-packages/wakatime/packages/requests/sessions.py\", line 555, in post\n return self.request(\'POST\', url, data=data, json=json, kwargs)\n File \"/home/phonnz/.local/lib/python2.7/site-packages/wakatime/packages/requests/sessions.py\", line 508, in request\n resp = self.send(prep, send_kwargs)\n File \"/home/phonnz/.local/lib/python2.7/site-packages/wakatime/packages/requests/sessions.py\", line 618, in send\n r = adapter.send(request, **kwargs)\n File \"/home/phonnz/.local/lib/python2.7/site-packages/wakatime/packages/requests/adapters.py\", line 502, in send\n raise ProxyError(e, request=request)\nProxyError: HTTPSConnectionPool(host=\'api.wakatime.com\', port=443): Max retries exceeded with url: /api/v1/users/current/heartbeats.bulk (Caused by ProxyError(\'Cannot connect to proxy.\', NewConnectionError(\'<urllib3.connection.VerifiedHTTPSConnection object at 0x7ffb39a33ed0>: Failed to establish a new connection: [Errno 111] Connection refused\',)))\n'}"}

The "now" value is accurate and I don't have any proxy in the network.

And for VS Code case, the error is:

Error: Command failed: python3 /home/user/.vscode/extensions/wakatime.vscode-wakatime-2.2.1/wakatime-master/wakatime/cli.py

And I see the wakatime-master.zip with size 0 at ~/.vscode/extensions/wakatime.vscode-wakatime-2.2.1

Thnx in advance

alanhamlett commented 4 years ago

What if you restart Vscode, does that same error appear again after the plugin initializes?

lukaswilkeer commented 4 years ago

I'm having the same trouble, but the wakatime are not logging any errors.

Visual, Sublime, zsh, vim, etc. In that case, keeps initializing until appear a error message.

I change the default binaries of python to python3 and the error continus, but this time keeps initializing and doesn't inform that an error occur on a while until that finally conclude with the error message on VSCode and Sublime.

Note that debug flag is enabled and not logging any error.

phonnz commented 4 years ago

What if you restart Vscode, does that same error appear again after the plugin initializes?

The same, I have tried update, reinstall, restart the editor, and I get mainly this error

{'ProxyError': u\"HTTPSConnectionPool(host='api.wakatime.com', port=443): 
    Max retries exceeded with url: /api/v1/users/current/heartbeats.bulk (Caused by ProxyError('Cannot connect to proxy.', 
    NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f63ea5bbf90>: Failed to establish a new connection: [Errno 111] Connection refused',
    )))\", 'traceback': 'Traceback (most recent call last):\\n  File \"/home/phonnz/.local/lib/python2.7/site-packages/wakatime/api.py\", 
    line 111, in send_heartbeats\\n    verify=ssl_verify)\\n  File \"/home/phonnz/.local/lib/python2.7/site-packages/wakatime/packages/requests/sessions.py\", 
    line 557, in post\\n    return self.request(\\'POST\\', url, data=data, json=json, **kwargs)\\n  
    File \"/home/phonnz/.local/lib/python2.7/site-packages/wakatime/packages/requests/sessions.py\", line 508, in request\\n    
    resp = self.send(prep, **send_kwargs)\\n  File \"/home/phonnz/.local/lib/python2.7/site-packages/wakatime/packages/requests/sessions.py\", 
    line 620, in send\\n    r = adapter.send(request, **kwargs)\\n  File \"/home/phonnz/.local/lib/python2.7/site-packages/wakatime/packages/requests/adapters.py\", 
    line 502, in send\\n    raise ProxyError(e, request=request)\\nProxyError: HTTPSConnectionPool(host=\\'api.wakatime.com\\', port=443): 
    Max retries exceeded with url: /api/v1/users/current/heartbeats.bulk (Caused by ProxyError(\\'Cannot connect to proxy.\\', 
    NewConnectionError(\\'<urllib3.connection.VerifiedHTTPSConnection object at 0x7f63ea5bbf90>: Failed to establish a new connection: [Errno 111] Connection refused\\',)))
    \\n'}
phonnz commented 4 years ago

Finally, after lot of tests, also the edition of the api.py and sessions.py files, I found the reason. When I was debugging the chrome extension, I saw an error saying there was a problem with cross-site cookie, something like I had a different cookie of where/to I was making the request, I uninstalled the plugin on zsh, VS code and chrome extension, cleaned the cookies and now everything is working.

So now, the error of https connection refused makes sense, unfornately I didn't copy the error in order to leave it here for the future or to patch it at least in the logs of terminal and Code plugins.

lukaswilkeer commented 4 years ago

@phonnz any suggestion to do when no logs are been recorded?

Wakatime CLI and plugins up to date.

alanhamlett commented 4 years ago

@phonnz from your error message it seems related to an invalid or missing proxy setting:

Caused by ProxyError('Cannot connect to proxy.')

phonnz commented 4 years ago

@phonnz any suggestion to do when no logs are been recorded?

Wakatime CLI and plugins up to date.

Not really because I haven't had that issue, but I would start watching if the file .wakatime.cfg really has set debug=true
and then watch the .wakatime.log file when you execute commands like

python3 ~/.vscode/extensions/wakatime.vscode-wakatime-2.2.1/wakatime-master/wakatime/cli.py 

And then adding more actions like

python3 ~/.vscode/extensions/wakatime.vscode-wakatime-2.2.1/wakatime-master/wakatime/cli.py --file ~/some-file.js
alanhamlett commented 4 years ago

@lukaswilkeer with debug mode enabled you should have logs both in your vscode console window and wakatime.log file:

lukaswilkeer commented 4 years ago

@alanhamlett to me, uninstaling ad installing the wakatime plugin solved the equation.