Vscode-restclient: excludeHostsForProxy setting doesn't work in the last version

Created on 15 Oct 2018  路  13Comments  路  Source: Huachao/vscode-restclient

Hi and thank you for you great job on this extension!

I found a potential issue in the last version (0.20.2) related to the excludeHostsForProxy setting, it seems to be ignored.

I tried to uninstall the new version in favour of an old one (0.19.0) and with the old version the setting works properly.

Has anything changed in the settings' definition in the last release?

Steps to reproduce the error:

  1. Being behind a proxy
  2. Set proxy in VS Code
  3. Run a webservice locally
  4. Update excludeHostsForProxy setting like this: "rest-client.excludeHostsForProxy": ["localhost"]
  5. Make a request to your webservice (i.e. GET http://localhost:8080) -> Receive: Proxy Error response

Thank you,
Federico

bug

All 13 comments

@Fed29 I can't repro your case, and could you please show me the http.proxy, rest-client. excludeHostsForProxy and your request url again which you fail on your test.

Here are my settings:

{
    "http.proxy": "http://proxy:8080",
    "http.proxyStrictSSL": false,
    "rest-client.excludeHostsForProxy": ["localhost","127.0.0.1"]
}

This is the request I trigger:

GET http://127.0.0.1:50201

With the rest-client 0.19.0 the request works.
With the rest-client 0.20.2 (and also with the 0.20.1) the request doesn't work. It seems it is forwarded to the proxy which reply with HTTP 403 Forbidden because I'm trying to connect to proxy's localhost.

Thank you!
Federico

@Fed29 I still can't repro your case, and could you please update the http.proxy to an not exist site like http://no-exist.com:8080, and check if sending request tohttp://127.0.0.1:50201 will direct traffic that site, if so, an error will pop like getaddrinfo ENOTFOUND no-exist.com no-exist.com:8080

This tip helped me a lot to make more tests, I figured out where the problem come from and I found a way to make the latest version of the extension works.

First of all I work on Windows 10 and I have HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment variable because I need them in order to make some other tools works.

Removing those variables the 0.20.2 extension works as expected.

I understood that each call pass through the vs-code proxy (the one set in the settings) and correctly use the excludeHostsForProxy extension setting.
Then the REST calls pass through the proxy set in the HTTP_PROXY env variable, using the NO_PROXY variable as exclude list.

Steps to reproduce are:

  • Setup these vs-code settings:
{
    "http.proxy": "http://not-exists-2:8080",
    "http.proxyStrictSSL": false,
    "rest-client.excludeHostsForProxy": ["127.0.0.1"]
}
  • Setup the following env variable:
HTTP_PROXY = "http://not-exists-1:8080"
NO_PROXY = localhost
  • Trigger the call GET http://127.0.0.1:50201 -> ERROR: getaddrinfo ENOTFOUND not-exists1 not-exists1:8080
  • Update env variable NO_PROXY = localhost,127.0.0.1
  • Trigger the call GET http://127.0.0.1:50201 -> OK
  • Update vs-code setting "rest-client.excludeHostsForProxy": []
  • Trigger the call GET http://127.0.0.1:50201 -> ERROR: getaddrinfo ENOTFOUND not-exists2 not-exists2:8080

ATTENTION: you should restart vs-code everytime you update an env variable.

In my case I cannot delete those variables because thay are used by other tools and In my opinion this behavior is a bit counter-intuitive.

So the question is: did your code now consider environment variables in addition to the vs-code settings or did you update some depencies?

Do you thing this behavior can be fixed?

Thank you
Federico

@Fed29 this behavior is consistent with VSCode, as you can see comments of VSCode as following// The proxy setting to use. If not set will be taken from the http_proxy and https_proxy environment variables. "http.proxy": "", VSCode will take the environment variables into consideration, so does this extension.

@Huachao ok, now it's clear to me and I found a workaround.
But I understand the VSCode setting description in a different way: if the setting is filled the environment variables are ignored. The extension always consider the env variables, regardless of the setting (so this behavior is not consistent with VSCode).

In any case the extension's behavior changed since the 0.20.x release, it was different in the previous ones (using the same version of vscode - 1.28.2) and in my opinion was consistent with VSCode in the older versions.

Thanks for your support,
Federico

@Fed29 actually I am a little bit confused about what you said. Do you mean even if you set the setting in VSCode, it will still respect the environment variables? I cannot make this conclusion from your earlier test

Yes @Huachao , exactly but only in the case you use the "rest-client.excludeHostsForProxy" setting.

Please, try the test I posted earlier:

VSCode Settings:

{
    "http.proxy": "http://not-exists-2:8080",
    "http.proxyStrictSSL": false,
    "rest-client.excludeHostsForProxy": ["127.0.0.1"]
}

Env Variables (restart VSCode after the edit)

HTTP_PROXY = "http://not-exists-1:8080"
NO_PROXY = localhost

At this point the VSCode proxy should be "http://not-exists-2:8080", do you agree?

Send the request to GET http://127.0.0.1:50201 and it shouldn't use proxy, right?

But you will receive an error like _"ERROR: getaddrinfo ENOTFOUND not-exists1 not-exists1:8080"_ this means the extension try to use the proxy in the env variable, that should be "overrided" by the VSCode proxy setting and excluded by the "rest-client.excludeHostsForProxy" setting.

@Fed29 Thanks for your feedback, I have fixed the inconsistent behavior and will publish this fix in next release.

@Fed29 you can try the latest version 0.20.3 to verify

@Huachao it works as expected

@Huachao, it is still strange for me. I have the HTTP_PROXY env variable set, so I leave the http.proxy property empty. According to the note above the proxy setting "If not set will be taken from the http_proxy and https_proxy environment variables."
But in this case the excludeHostsForProxy property is not considered.
When I set the http.proxy to the same value as the HTTP_PROXY env variable is set, the excludeHostsForProxy is considered and the requests do not go to the proxy ( as expected ).
One extra difference, the "NO_PROXY" environment variable is unset for me.

@verebes nice catch, it's really the current expected behavior, excludeHostsForProxy only works for the http.proxy setting in vscode. And if you leave it out, you need to set the NO_PROXY environment variable.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abenedykt picture abenedykt  路  18Comments

heneds picture heneds  路  32Comments

chewlm86 picture chewlm86  路  13Comments

mtxr picture mtxr  路  13Comments

Odonno picture Odonno  路  22Comments