diff --git a/autoendpoint/src/server.rs b/autoendpoint/src/server.rs index 663677527..d57ec8303 100644 --- a/autoendpoint/src/server.rs +++ b/autoendpoint/src/server.rs @@ -24,6 +24,7 @@ use actix_web::{ use cadence::StatsdClient; use fernet::MultiFernet; use std::sync::Arc; +use std::time::Duration; #[derive(Clone)] pub struct ServerState { @@ -51,7 +52,11 @@ impl Server { settings.router_table_name.clone(), settings.message_table_name.clone(), )?); - let http = reqwest::Client::new(); + let http = reqwest::ClientBuilder::new() + .connect_timeout(Duration::from_millis(settings.connection_timeout_millis)) + .timeout(Duration::from_millis(settings.request_timeout_millis)) + .build() + .expect("Could not generate request client"); let fcm_router = Arc::new( FcmRouter::new( settings.fcm.clone(), diff --git a/autoendpoint/src/settings.rs b/autoendpoint/src/settings.rs index 9c5e3308c..1047992c1 100644 --- a/autoendpoint/src/settings.rs +++ b/autoendpoint/src/settings.rs @@ -27,6 +27,9 @@ pub struct Settings { pub auth_keys: String, pub human_logs: bool, + pub connection_timeout_millis: u64, + pub request_timeout_millis: u64, + pub statsd_host: Option, pub statsd_port: u16, pub statsd_label: String, @@ -53,6 +56,8 @@ impl Default for Settings { crypto_keys: format!("[{}]", Fernet::generate_key()), auth_keys: r#"["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB="]"#.to_string(), human_logs: false, + connection_timeout_millis: 1000, + request_timeout_millis: 3000, statsd_host: None, statsd_port: 8125, statsd_label: "autoendpoint".to_string(),