diff --git a/ext_federation/src/client/federation_client.rs b/ext_federation/src/client/federation_client.rs index e0840e1..e4e5d4e 100644 --- a/ext_federation/src/client/federation_client.rs +++ b/ext_federation/src/client/federation_client.rs @@ -4,6 +4,7 @@ use headers::UserAgent; use hyper::body::Bytes; use reqwest::{redirect::Policy, Client, RequestBuilder}; use serde_json::Value; +use std::time::Duration; use thiserror::Error; use tokio::pin; use url::Url; @@ -58,6 +59,7 @@ impl FederationClient { let client = Client::builder() .https_only(force_https) .redirect(Policy::limited(5)) + .connect_timeout(Duration::from_secs(timeout_seconds)) .build()?; Ok(FederationClient { @@ -119,7 +121,7 @@ impl FederationRequestBuilder<'_> { async fn send_stream( self, - ) -> Result>, FederationClientError> + ) -> Result>, FederationClientError> { let mut body = self .builder @@ -147,7 +149,7 @@ impl FederationRequestBuilder<'_> { let sleep = tokio::time::sleep(tokio::time::Duration::from_secs( self.client.timeout_seconds, )) - .fuse(); + .fuse(); tokio::pin!(sleep); let body = async move { @@ -159,7 +161,7 @@ impl FederationRequestBuilder<'_> { }) .await } - .fuse(); + .fuse(); pin!(body); diff --git a/src/service/federation_client.rs b/src/service/federation_client.rs index 856264c..d702548 100644 --- a/src/service/federation_client.rs +++ b/src/service/federation_client.rs @@ -15,18 +15,18 @@ pub(super) fn new_federation_client_service( FederationClient::new( true, 256000, - 35, + 25, UserAgent::from_str(&format!( "magnetar/{} (https://{})", config.branding.version, config.networking.host )) - .into_diagnostic()?, + .into_diagnostic()?, ) - .into_diagnostic() + .into_diagnostic() } pub(super) fn new_ap_client_service( federation_client: impl AsRef + Send + Sync + 'static, -) -> impl ApClientService { +) -> impl ApClientService { ApClientServiceDefaultProvider::new(federation_client) }