summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerguey Parkhomovsky <xindigo@gmail.com>2026-03-21 11:46:51 -0700
committerSerguey Parkhomovsky <xindigo@gmail.com>2026-03-21 11:46:51 -0700
commit22292eccabcdf36129845e6fd03d0c5e2516c3be (patch)
treea29bb36484569b9f3f567adab0f78775d88ab618
parent54716d737ac4a84eeb65e1c41a4c3096c5dbc4c2 (diff)
Add timeout to http client
-rw-r--r--src/main.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 8018bed..433209c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -127,7 +127,13 @@ async fn fetch_prusa(
}
async fn poll_prusa(name: String, host: String, api_key: String, state: StateMap) {
- let client = Client::new();
+ let client = Client::builder()
+ .timeout(Duration::from_secs(10))
+ .build()
+ .unwrap_or_else(|e| {
+ error!(name, error = %e, "Failed to build HTTP client");
+ process::exit(1);
+ });
loop {
if let Err(e) = fetch_prusa(&client, &name, &host, &api_key, &state).await {
error!(name, error = %e, "Error polling Prusa printer");