Getting Error: Connect(Timeout) with actix_web client

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("") // <- Create request builder
.send() // <- Send http request
.and_then(|mut response| { // <- server http response
println!("Response: {:?}", response);
.map(|body| println!("Downloaded: {:?} bytes", body))

Please use code fences to formst your code like this,

// your code here

thanks i added the fences to the code.

This StackOverflow post seems relavant

Tldr; use streaming instead of body

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.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.