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

Why does specifying the proxy address not work? #892

Open
1 task done
stricklandye opened this issue Jan 24, 2024 · 0 comments
Open
1 task done

Why does specifying the proxy address not work? #892

stricklandye opened this issue Jan 24, 2024 · 0 comments
Labels

Comments

@stricklandye
Copy link

stricklandye commented Jan 24, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Hi there.
I want to specify proxy address for websocket connection instead of setting environment variables http_proxy and https_proxy. I copied code from#107 and it's like:

dg.Dialer = &websocket.Dialer{
  Proxy: http.ProxyURL(&url.URL{
	  Scheme: "http", // or "https" depending on your proxy
	  Host:   "localhost:7890",
  }),
}

I have also tried to use https but it still doesn't work. However, if use http_proxy and https_proxy env variables with http.ProxyFromEnvironment, it works fine. code snippet:

os.Setenv("http_proxy", "http://localhost:7890")
os.Setenv("https_proxy", "http://localhost:7890")
os.Setenv("HTTP_PROXY", "http://localhost:7890")
os.Setenv("HTTPs_PROXY", "http://localhost:7890")
dg, err := discordgo.New("Bot " + botToken)
dg.Dialer = &websocket.Dialer{
   Proxy: http.ProxyFromEnvironment,
}

Expected Behavior

I want to specify proxy address for websokct addres instead of setting environment variables http_proxy and https_proxy. Because it affects other http connection that don't want to go through the proxy.

Steps To Reproduce

No response

Anything else?

I am using discordgo which uses this repo inside. So it maybe not a right place to open the issue here. Hope someone could explain why setting proxy for Dialer does not work as I expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant