seanmonstar / reqwest

An easy and powerful Rust HTTP Client
https://docs.rs/reqwest
Apache License 2.0
9.92k stars 1.12k forks source link

os error 104: Connection reset by peer, when I use rustls #1039

Closed erfanium closed 4 years ago

erfanium commented 4 years ago

url: https://api.kavenegar.com/v1

Cargo.toml

[dependencies]
reqwest = { version = "0.10.8", default-features = false, features = ["rustls-tls", "stream", "gzip", "brotli"] }
tokio = { version = "0.2", features = ["full"] }

main.rs

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let res = reqwest::Client::builder()
        .danger_accept_invalid_certs(true)
        .build()
        .unwrap()
        .get("https://api.kavenegar.com/v1")
        .send()
        .await?;

    println!("res: is {}", res.status());

    Ok(())
}

log result:

Error: reqwest::Error { kind: Request, url: "https://api.kavenegar.com/v1", source: hyper::Error(Connect, Custom { kind: Other, error: Os { code: 104, kind: ConnectionReset, message: "Connection reset by peer" } }) }

I don't have any problem when I use openssl or native-tls What's wrong?

erfanium commented 4 years ago

Related: https://github.com/denoland/deno/issues/7528

seanmonstar commented 4 years ago

I'm sorry, I don't know. Since you said it works with openssl, then it seems like a problem with rustls. It may be worth opening issue there.

erfanium commented 4 years ago

@seanmonstar OK, I'm closing this now