From be1dc01d9e972b2ddcf06a3b50c758e55ca443bf Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 20 Oct 2022 16:57:47 +0200 Subject: [PATCH] Add 5s timeout to LiveKit API requests Co-Authored-By: Nathan Sobo --- crates/live_kit_server/src/api.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/live_kit_server/src/api.rs b/crates/live_kit_server/src/api.rs index 43e01ce880..f78cd8f6fb 100644 --- a/crates/live_kit_server/src/api.rs +++ b/crates/live_kit_server/src/api.rs @@ -3,7 +3,7 @@ use anyhow::{anyhow, Result}; use async_trait::async_trait; use prost::Message; use reqwest::header::CONTENT_TYPE; -use std::{future::Future, sync::Arc}; +use std::{future::Future, sync::Arc, time::Duration}; #[async_trait] pub trait Client: Send + Sync { @@ -29,7 +29,10 @@ impl LiveKitClient { } Self { - http: reqwest::Client::new(), + http: reqwest::ClientBuilder::new() + .timeout(Duration::from_secs(5)) + .build() + .unwrap(), url: url.into(), key: key.into(), secret: secret.into(),