PlatformIO IDE in VSCode can't connect to the Internet - blocked by Proxy


#1

Hey there!

I’m struggeling a bit trying to get PlatformIO working behind my corporate proxy. VSCode grabs the Proxy-settings from the wpad-config in Windows (10) and asks me for credentials on startup. That way I was able to download PIO from the extension manager.
The first problem arose as VSCode was not able to download cpptools automatically, so i downloaded the *.vsix manually. Then I had to manually setup the virtual python environment.
PIO is working now but is blocked by the proxy. I can’t download libaries and if I want to create a new project the board drop-down menu stays empty (0 available). Setting the environment variables HTTP_PROXY and HTTPS_PROXY didn’t help.

Thanks for any help in advance!
Thomas


#2

See http://docs.python-requests.org/en/master/user/advanced/#proxies

If you restart you machine, open PIO IDE Terminal and type

echo %HTTP_PROXY%
echo %HTTPS_PROXY%

Do you see real values?


#3

Yes, the PIO IDE Terminal shows the environment variables values after a restart if I query them like that.

I tried setting the variables with and without my credentials, both variants didn’t enable PIO IDE to connect to the internet.

Giving the proxy-settings to pip in a similar form --proxy="http://<username>:<password>@proxy.hs-karlsruhe.de" works to download python packages.

I tried to use the request-package in python like suggested on your link which resulted in an error:

requests.exceptions.ProxyError: HTTPSConnectionPool(host=‘proxy.hs-karlsruhe.de’, port=8888): Max retries exceeded with url: http://example.org/ (Caused by ProxyError(‘Cannot connect to proxy.’, error(‘Tunnel connection failed: 403 Forbidden’,)))

EDIT: I fixed it
http://<username>:<password>@proxy.hs-karlsruhe.de:8888/
Environment variable has to be formated exactly that way. I never thought the last slash could be important…


Proxy Issue in VS Code
#4

So, could you provide the final instruction here? I would be thankful! We will create a separate page in FAQ and describe it.


#5

To get the PIO IDE in VSCode on Windows 10 to connect to the internet through a proxy I had to set two environment variables for my user.

HTTP_PROXY: http://<username>:<password>@proxy.hs-karlsruhe.de:8888/
HTTPS_PROXY: http://<username>:<password>@proxy.hs-karlsruhe.de:8888/

Important for me (maybe obvious for someone with more knowledge :wink: ) was that

  • don’t include a domain
  • protocol in front of the username has to be http:// not https://
  • slash at the end is important
  • restart computer

How to set a proxy for PlatformIO CLI?
#6

Does VSCode use the same environment variables? Should we use one of these methods?


#7

At the moment VSCode seems to grab the proxy-settings defined in my windows-settings. There I listed the path to a wpad.dat script that sets up the proxy. Everytime I start up VSCode I get a prompt to input my credentials (as shown in the VSCode-docs you linked). There it says the proxy is at port 8010 and not 8888. Port 8010 is the one defined on the wpad so I know VSCode is using that instead of the environment variables where i used 8888. Wierdly I get that exact same prompt a second time when the PIO Home Tab is loading in, altrough PIO doesn’t seem to use it.

If I delete the wpad-path in the windows-settings leaving the environment variables the only thing defining the proxy VSCode can’t connect to the internet anymore (can’t download extensions i.e.). Doing so will still result in PIO beeing able to connect to the internet…

Something else I tried was to set "http.proxyAuthorization" and "http.proxy" in the VSCode settings.json, but I could not get a working connection that way for neither VSCode nor the PIO IDE.

In the VSCode settings.json it says

 // The value to send as the 'Proxy-Authorization' header for every network request.
 "http.proxyAuthorization": null

 // The proxy setting to use. If not set will be taken from the http_proxy and https_proxy environment variables.
 "http.proxy": ""

I think the problem is, that PIO needs to have the credentials/authentification in the environmental variables itself while VSCode just wants the address in the variable and the credentials seperatly.


#8

I think we can use this the same file and automatically propagate all system environment variables for Python.

How did you set them? Sorry, I’m not a Windows user.

Who did create this file? What is inside this file? Could you provide an example?

I’m not sure that this a good idea :frowning:


#9

In the windows settings is something like this


there I listed the address to the setup-script provided by out University IT-department. If “automatically detect settings” is activated it should be found automatically by the computer in the intranet (to my understanding), but that doesn’t work on some computers so you have to input it manually.
The file should be downloadable from anywhere if you want to take a look (wpad.dat).

Well, that’s the same way Firefox handles it (get a prompt there too every time I start it). And it feels better than having you credentials in your environmental variables in plain text.

Btw., maybe you have read that already, maybe not… https://github.com/Microsoft/vscode/issues/12588