Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check and improve proxy support #336

Open
koettert opened this issue Apr 16, 2024 · 4 comments
Open

Check and improve proxy support #336

koettert opened this issue Apr 16, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@koettert
Copy link
Contributor

koettert commented Apr 16, 2024

The goal of this ticket is to ensure that all geospatial nodes use the newly available proxy settings. With AP-20960 that was released with KNIME AP 5.2 the Python framework sets the proxy information configured via the HTTP_PROXY and HTTPS_PROXY environment variables (via os.setenv(...) os.environ). In addition the proxy settings can be retrieved via knext.get_proxy_settings()

For debugging and testing we can use https://mitmproxy.org/ and Ask Adrian for help.

Steps to do:

  1. Install and setup https://mitmproxy.org/ or any other tool to debug proxy usage
  2. Setup the proxy in KNIME AP (needs to be version 5.2 or newer) by opening Preferences->General->Network Connections and then editing the http and https entries
  3. Restart KNIME AP
  4. Execute different Geospatial nodes especially the OSM nodes to see if they use the proxy settings or ignore it
@koettert koettert added the enhancement New feature or request label Apr 16, 2024
@koettert koettert added this to the Release 1.3 milestone Apr 16, 2024
@koettert koettert self-assigned this Apr 16, 2024
@koettert koettert assigned wybert and UrbanGISer and unassigned koettert May 21, 2024
@wybert
Copy link
Contributor

wybert commented May 24, 2024

I just did a test on Mac M2 with KNIME 5.2.3, below is what I found,

  1. Our extension will not use the proxies set in KNIME preferences.
  2. The Python Script node will not use the proxies set in KNIME preferences.
  3. To enable Python Script node and one of our extension node to use proxies set in KNIME preferences, we need add some code like in the following,
import os
os.environ['HTTP_PROXY'] = 'http://localhost:8080'
os.environ['HTTPS_PROXY'] = 'http://localhost:8080'
  1. It will work for most of the code, but not for the OSMNx package, I find an issue here, but I can't get it work.
  2. Dose os.setenv(...) not work but os.environ dose?
  3. The OSMnx also have a setting module with requests_kwargs, which could specify the proxies, but I can't get it work too.

@koettert
Copy link
Contributor Author

Once os.environ was set all nodes that use the request package used the proxy. But the OSMnx nodes still didn't work even so the documentation states that it uses the request package that can be configure via _kwargs.

@koettert to check with the Python team about: "Does os.setenv(...) not work but os.environ dose?"

@wybert please check out the above mentioned solutions and try to understand from reading their code and the OSMnx code why setting the proxy via os.environ doesn't work

@wybert
Copy link
Contributor

wybert commented May 28, 2024

I just did a test on Mac M2 with KNIME 5.2.3, below is what I found,

  1. Our extension will not use the proxies set in KNIME preferences.
  2. The Python Script node will not use the proxies set in KNIME preferences.
  3. To enable Python Script node and one of our extension node to use proxies set in KNIME preferences, we need add some code like in the following,
import os
os.environ['HTTP_PROXY'] = 'http://localhost:8080'
os.environ['HTTPS_PROXY'] = 'http://localhost:8080'
  1. It will work for most of the code, but not for the OSMNx package, I find an issue here, but I can't get it work.
  2. Dose os.setenv(...) not work but os.environ dose?
  3. The OSMnx also have a setting module with requests_kwargs, which could specify the proxies, but I can't get it work too.

@koettert There is a mistake when testing with OSMNx, OSMNx will use cache for executed query. That's why OSMNx seems never use proxy during my test (It actually doesn't make a request at all).
After setting ox.settings.use_cache = False, OSMNx will use proxies both set by

import os
os.environ['HTTP_PROXY'] = 'http://localhost:8080'
os.environ['HTTPS_PROXY'] = 'http://localhost:8080'

Or

proxies = {
    "http": "http://localhost:8080",
    "https": "http://localhost:8080",
}

ox.settings.requests_kwargs = {'proxies': proxies, 'verify': False}

@koettert koettert modified the milestones: Release 1.3, Release 1.4 Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants