Skip to content

Send events without proxy when http_proxy is configured as env variable #178

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

Closed
cichy767 opened this issue Nov 24, 2018 · 6 comments · Fixed by #309
Closed

Send events without proxy when http_proxy is configured as env variable #178

cichy767 opened this issue Nov 24, 2018 · 6 comments · Fixed by #309
Labels
Help wanted Extra attention is needed

Comments

@cichy767
Copy link

Hi,
I have problem with configuration of sentry_sdk. My code is behind corporate proxy and http_proxy is configured on machine as env variable (required when I want to install something via pip for example). Also I have env variable no_proxy where I added ip address for host where sentry is working (this ip is inside corporate network). When I try send event to sentry I got return code 403 (proxy refuse request). Probably sentry_sdk automacally fetch proxy from http_proxy env but ignore no_proxy. When I remove http_proxy from env everything is working. How can I configure python_sdk to ignore my http_proxy env variable? My code:

import logging
import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration


sentry_logging = LoggingIntegration(
    level=logging.INFO,       
    event_level=logging.ERROR 
)
sentry_sdk.init(
    dsn="<dsn>",
    integrations=[sentry_logging],
    debug=True,
)
@untitaker
Copy link
Member

Hi, yes there's currently no way to disable http_proxy if you have an envvar. I am not sure if no_proxy is easy to implement.

@untitaker untitaker added enhancement Help wanted Extra attention is needed labels Nov 26, 2018
@gelmiro
Copy link

gelmiro commented Nov 27, 2018

The same problem behid proxy. In this situation sentry_sdk is difficult to use. Maybe better solution will be use requests instead urllib3? Requests can handle no_proxy out of the box.

@amiraliakbari
Copy link

I want to add that switching to requests library can have other benefits like supporting SOCKS proxies. Currently, providing SOCKS proxy to http_proxy parameter results in ProxySchemeUnknown exception. To fix that with urllib3, you should explicitly check for socks:// schemes and use SOCKSProxyManager instead of ProxyManager, but requests handles it seamlessly.

@untitaker
Copy link
Member

To keep this issue updated: We discussed this internally and decided on a hard rule not to use requests. The reason for this is that we would like to explicitly control which behavior we support (since all of the new SDKs share a single piece of documentation describing that behavior, and the behavior across SDKs and across languages should be the same), and requests ideologically is the opposite of that: I for one was unaware that requests reads environment variables like that, even though I've been using it for quite a while.

I would propose that we keep the current, simple, stupid proxying behavior, but add a new flag that disables any access to the process environment. Is this an acceptable fix?

@kennell
Copy link

kennell commented Feb 21, 2019

I would propose that we keep the current, simple, stupid proxying behavior, but add a new flag that disables any access to the process environment. Is this an acceptable fix?

The no_proxy env var is widely used. I strongly feel that if an application reads from http_proxy it should also respect the no_proxy variable. Please consider supporting it, thanks.

crepererum added a commit to crepererum/sentry-python that referenced this issue Mar 27, 2019
crepererum added a commit to crepererum/sentry-python that referenced this issue Apr 24, 2019
untitaker pushed a commit that referenced this issue Apr 25, 2019
* split and extend proxy tests

* fix HTTP fallback for proxy env vars

Fixes #308

* Fine-grained control over proxy selection.

Fixes #178
@untitaker
Copy link
Member

#838 actually adds support for no_proxy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants