Http client (reqwest) closed connection when server shutdown (warp)


I use warp as a server:

let r2 = warp::path("r2");
let route_2 = r2
        .and_then(handlers::post_handler); // post cmd_result to the database```

let routes = test_route


And i use a client with reqwest. Let's say:

        let client = reqwest::Client::new();

        let res ="http:// .... /r1")
                        .body("body 1")
=====> sleep 5 min for example
        let res ="http:// .... /r2")
                        .body("body 2")

If a shutdown the warp server during this 5 min sleep, the reqwest client shutdown too. I would like to prevent that, and that the client still continues to submit request to the server.

Any idea?


If your server is down I`d guess your call to will return some kind of error. Are you treating this error? Maybe that will cause panic! ?

P.S. I am guessing this without any prior knowledge of reqwest

Well i think it works but it wasn't. I was too fast.

The error is:

Error: reqwest::Error { kind: Request, url: "", source: hyper::Error(Connect, ConnectError("tcp connect error", Os { code: 111, kind: ConnectionRefused, message: "Connection refused" })) }

I handle the erreur like:

let r: bool = match res.status() {
            StatusCode::OK => {
            _ => {
                println!("HTTP server is not responding ...");

But the code never goes into the false* case

I don't handle the error the right way.

This is how to do:

let res =

match res {
       Err(e) => {println!("server not responding");},
       Ok(_) => {}, 

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.