i am trying to create a web client using actix_web, but getting Error: Connect(Timeout) error. is there a way to increase timeout settings ?
use actix_rt::System;
use actix_web::client::Client;
use futures::future::Future;
use futures::lazy;
use actix_http::Error;
fn main() -> Result<(), Error> {
System::new("test").block_on(lazy(|| {
let mut client = Client::default();
client.get("https://example.org") // <- Create request builder
.send() // <- Send http request
.from_err()
.and_then(|mut response| { // <- server http response
println!("Response: {:?}", response);
response
.body()
.from_err()
.map(|body| println!("Downloaded: {:?} bytes", body))
})
}))
}
Please use code fences to formst your code like this,
```rust
// your code here
```
thanks i added the fences to the code.
well the problem is timeout in sending the request, I think streaming will only work once I got the response and the response will come once request is send.
the request is getting timeout in first place as the server which I am trying to connect takes 4-5 sec to respond with result.
correct me if I am wrong.
You set the timeout with ClientBuilder::timeout
and then finalize the builder to get a Client
with the configured timeout.
1 Like
system
Closed
December 25, 2019, 11:14pm
7
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.