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

Could not establish a websocket connection through a proxy #2479

Open
forsummer opened this issue Jun 29, 2023 · 0 comments
Open

Could not establish a websocket connection through a proxy #2479

forsummer opened this issue Jun 29, 2023 · 0 comments
Labels
bug Something misbehaves or is not working. gateway Related to the `gateway` module. http Related to the `http` module.

Comments

@forsummer
Copy link

Unable to establish a websocket connection through a proxy, the code is as follows:

let intents = GatewayIntents::MESSAGE_CONTENT |
    GatewayIntents::GUILD_MESSAGES |
    GatewayIntents::DIRECT_MESSAGES;

let http = HttpBuilder::new(bot_token)
    .application_id(app_id)
    .proxy("http://localhost:7890")
    .map_or_else(|e| panic!("{}", e), |h| h.build());

let mut bot = ClientBuilder::new_with_http(http, intents)
    .event_handler(Handler)
    .await
    .expect("Build bot client failed");

bot.start()
    .await
    .expect("Bot connect success");

The error message is as follows:

Build bot client failed: Http(Request(reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("discord.com")), port: None, path: "/api/v10/gateway", query: None, fragment: None }, source: hyper::Error(Connect, ConnectError("tcp connect error", Os { code: 110, kind: TimedOut, message: "Connection timed out" })) }))

PS: Strangely enough, websocket connections can be established normally using wscat (via http proxy)

@arqunis arqunis added bug Something misbehaves or is not working. http Related to the `http` module. gateway Related to the `gateway` module. labels Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something misbehaves or is not working. gateway Related to the `gateway` module. http Related to the `http` module.
Projects
None yet
Development

No branches or pull requests

2 participants