From 6ee9b6e7c9004d830353c0fe27f650b8def3b4d9 Mon Sep 17 00:00:00 2001 From: _ <_@_> Date: Fri, 2 Apr 2021 20:58:19 -0500 Subject: [PATCH] :bug: bug: ptth_server: add 30-second timeout for _only_ http_listen requests --- crates/ptth_relay/src/server_endpoint.rs | 2 +- crates/ptth_server/src/lib.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/ptth_relay/src/server_endpoint.rs b/crates/ptth_relay/src/server_endpoint.rs index 64a5266..6319d0e 100644 --- a/crates/ptth_relay/src/server_endpoint.rs +++ b/crates/ptth_relay/src/server_endpoint.rs @@ -133,7 +133,7 @@ pub async fn handle_listen ( Ok (error_reply (StatusCode::INTERNAL_SERVER_ERROR, "Server error")?) }, }, - _ = tokio::time::sleep (Duration::from_secs (30)).fuse () => { + _ = tokio::time::sleep (Duration::from_secs (25)).fuse () => { debug! ("Timed out http_listen for server {} {}", watcher_code, listen_id); return Ok (error_reply (StatusCode::NO_CONTENT, "No requests now, long-poll again")?) } diff --git a/crates/ptth_server/src/lib.rs b/crates/ptth_server/src/lib.rs index 66db7d7..c1a558c 100644 --- a/crates/ptth_server/src/lib.rs +++ b/crates/ptth_server/src/lib.rs @@ -294,7 +294,9 @@ async fn run_server_loop ( debug! ("http_listen"); - let req_req = state.client.get (&format! ("{}/http_listen/{}", state.config.relay_url, state.file_server.metrics_startup.server_name)).send (); + let req_req = state.client.get (&format! ("{}/http_listen/{}", state.config.relay_url, state.file_server.metrics_startup.server_name)) + .timeout (Duration::from_secs (30)) + .send (); let err_backoff_delay = std::cmp::min (30_000, backoff_delay * 2 + 500);