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

unable to make socks5 to work #1625

Closed
Masber opened this issue Sep 12, 2022 · 2 comments
Closed

unable to make socks5 to work #1625

Masber opened this issue Sep 12, 2022 · 2 comments

Comments

@Masber
Copy link

Masber commented Sep 12, 2022

I am trying to make reqwest run with socks5, I have enabled the feature and I can access the endpoint:

curl -k -x socks5h://localhost:1080 -H 'Authorization: Bearer --REDACTED--' https://api-gw-service-nmn.local/apis/ims/healthz/ready
{}

My problem is that I can't make it to work in rust.

async fn main() -> Result<(), Box<dyn std::error::Error>> {

    let token = "--REDACTED--";
    let url = "https://api-gw-service-nmn.local/apis/ims/healthz/ready";

    let client = reqwest::Client::builder()
    .proxy(reqwest::Proxy::http("socks5://localhost:1080")?)
    .build()?;

    let resp = client.get(url).bearer_auth(token).send()
    .await?
    .json::<HashMap<String, String>>()
    .await?;

    println!("{:#?}", resp);
    
    Ok(())
}

This is the output I am getting:

   Compiling rest-client v0.1.0 (/home/msopena/ownCloud/Documents/tests/rust/rest-client)
    Finished dev [unoptimized + debuginfo] target(s) in 5.36s
     Running `target/debug/rest-client`
Error: reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("api-gw-service-nmn.local")), port: None, path: "/apis/ims/healthz/ready", query: None, fragment: None }, source: hyper::Error(Connect, ConnectError("dns error", Custom { kind: Uncategorized, error: "failed to lookup address information: Name or service not known" })) }

Any hint?

@seanmonstar
Copy link
Owner

Do you need the extra h in the scheme? socks5h://? I think that implies doing DNS on the proxy, right?

@Masber
Copy link
Author

Masber commented Sep 12, 2022

spot on!

@Masber Masber closed this as completed Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants