From d864a0569a809b6b8d9a6bee28cd8844d3a9a971 Mon Sep 17 00:00:00 2001 From: Kai Lueke Date: Thu, 21 Dec 2023 22:21:30 +0100 Subject: [PATCH] download_sysext: Set TCP keepalive option The download can hang for longer time if, e.g., the route goes down. To error out more quickly, enable the TCP keepalive option. --- src/bin/download_sysext.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bin/download_sysext.rs b/src/bin/download_sysext.rs index 614d18e..9107b49 100644 --- a/src/bin/download_sysext.rs +++ b/src/bin/download_sysext.rs @@ -341,7 +341,12 @@ fn main() -> Result<(), Box> { fs::create_dir_all(&temp_dir)?; // The default policy of reqwest Client supports max 10 attempts on HTTP redirect. - let client = Client::builder().connect_timeout(Duration::from_secs(HTTP_CONN_TIMEOUT)).timeout(Duration::from_secs(DOWNLOAD_TIMEOUT)).redirect(Policy::default()).build()?; + let client = Client::builder() + .tcp_keepalive(Duration::from_secs(HTTP_CONN_TIMEOUT)) + .connect_timeout(Duration::from_secs(HTTP_CONN_TIMEOUT)) + .timeout(Duration::from_secs(DOWNLOAD_TIMEOUT)) + .redirect(Policy::default()) + .build()?; // If input_xml exists, simply read it. // If not, try to read from payload_url.