diff --git a/conduwuit-example.toml b/conduwuit-example.toml index d3afc870..ff3a9d0d 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -340,7 +340,9 @@ # this to be high to account for extremely large room joins, slow # homeservers, your own resources etc. # -#federation_timeout = 300 +# Joins have 6x the timeout. +# +#federation_timeout = 60 # MSC4284 Policy server request timeout (seconds). Generally policy # servers should respond near instantly, however may slow down under diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index 7efd89f6..d35514f1 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -435,7 +435,9 @@ pub struct Config { /// this to be high to account for extremely large room joins, slow /// homeservers, your own resources etc. /// - /// default: 300 + /// Joins have 6x the timeout. + /// + /// default: 60 #[serde(default = "default_federation_timeout")] pub federation_timeout: u64, @@ -2474,7 +2476,7 @@ fn default_well_known_timeout() -> u64 { 10 } fn default_federation_conn_timeout() -> u64 { 10 } -fn default_federation_timeout() -> u64 { 25 } +fn default_federation_timeout() -> u64 { 60 } fn default_policy_server_request_timeout() -> u64 { 10 } diff --git a/src/service/client/mod.rs b/src/service/client/mod.rs index 85e6845f..46ba89c5 100644 --- a/src/service/client/mod.rs +++ b/src/service/client/mod.rs @@ -82,8 +82,13 @@ impl crate::Service for Service { synapse: base(config)? .dns_resolver(resolver.resolver.hooked.clone()) .connect_timeout(Duration::from_secs(config.federation_conn_timeout)) - .read_timeout(Duration::from_secs(305)) - .timeout(Duration::from_secs(120)) + .read_timeout(Duration::from_secs(config.federation_timeout.saturating_mul(6))) + .timeout(Duration::from_secs( + config + .federation_timeout + .saturating_mul(6) + .saturating_add(config.federation_conn_timeout), + )) .pool_max_idle_per_host(0) .redirect(redirect::Policy::limited(3)) .build()?,