0

I'm trying to make an https request to a third party API from my Actix Web Server. I'm using awc::Client to make the request. I'm running the server on Windows 10 with the openssl features enabled in the Cargo.toml file.

Here is the code that is running:

...

let client = Client::default();
let response = client.get("https://www.google.com")
    .set_header("User-Agent", "Actix-web")
    .send().await;

info!("Response: {:?}", response.unwrap());

Whenever I try to unwrap the result, I get this exception:

thread 'actix-rt:worker:0' panicked at 'called Result::unwrap() on an Err value: Connect(Timeout)'

How come I'm getting this exception? I'm guessing it's a configuration issue, but am unsure.

Herohtar
  • 5,347
  • 4
  • 31
  • 41

1 Answers1

0

If your latency is too high, try setting the timeout manually:

/*...*/

let client = Client::builder()
    .timeout(Duration::from_secs(5))
    .finish();

let response = client.get("https://www.google.com")
    .set_header("User-Agent", "Actix-web")
    .send().await;

info!("Response: {:?}", response.unwrap());

/*...*/
Timotej Leginus
  • 304
  • 3
  • 18
  • I've tried increasing the latency and that did not resolve my problem. I tried using the reqwest crate in a separate binary and I was able to make the request successfully. I am starting to think it might be an issue with the actix_web framework. – Samuel Labrador Dec 30 '21 at 04:24
  • Hmm, would be helpful creating an issue about it there. – Timotej Leginus Dec 30 '21 at 16:46