actix-web: bug: actix_web client unable to connect to any host on windows
Following example code always produces Error: Connect(Timeout)
:
use actix_rt::System;
use awc::Client;
use futures::future::{
Future,
lazy
};
fn main() {
System::new("weight_version").block_on(lazy(|| {
awc::Client::new().get("https://google.com") //any address here
.header("User-Agent", "Actix-web")
.send()
.map_err(|error| {
println!("Error: {:?}", error);
})
.and_then(|response| {
println!("Response: {:?}", response);
Ok(())
})
}));
}
actix_web::client::Client also produces same error:
use actix_rt::System;
use actix_web::client::Client;
use futures::future::{
Future,
lazy
};
fn main() {
System::new("weight_version").block_on(lazy(|| {
let client = Client::default();
client.get("https://www.rust-lang.org/")
.header("User-Agent", "Actix-web")
.send()
.map_err(|error| {
println!("Error: {:?}", error);
//Err(error)
})
.and_then(|response| {
println!("Response: {:?}", response);
Ok(())
})
}));
}
Tested on 3 totally different windows machines with following:
openssl version
OpenSSL 1.1.1c 28 May 2019
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 5
- Comments: 38 (10 by maintainers)
I have the same issue on my windows system while the same code works perfectly fine on linux.
I got it work by construct client this way but I still get very poor response time.
add rustls feature works fine
@Bhaal22 exactly the same for me:
very odd…
@rokit not quite, I’m just making a single request, using the actix-web async client (the request is to an endpoint that just fetches a fast responding web page). When using the actix-web HTTP client on Mac OS X, and in a debug build, I get a connect timeout error. In a release build, it works fine.
I’m using
reqwest
andweb::block
as a workaround for the actix-web client issue (request + block works fine).I’ve been getting the same error/behaviour on Mac OS X as well (the same code works fine on Linux for me).
The issue only seems to occur on debug builds too (perhaps because the request takes longer and times out?). Running under a release build works fine.
In case it’s of any use, this is the trace log output from my server. My server is just:
and the trace logging output: