diff --git a/src/service/sending/mod.rs b/src/service/sending/mod.rs index c666bc9445cb0ca07a2504a63a717e71b04f892a..c802278ba8319efa476ca614e9c0cee4e0f9a3e2 100644 --- a/src/service/sending/mod.rs +++ b/src/service/sending/mod.rs @@ -234,7 +234,8 @@ pub async fn send_federation_request<T>(&self, dest: &ServerName, request: T) -> { let permit = self.maximum_requests.acquire().await; let timeout = Duration::from_secs(self.timeout); - let response = tokio::time::timeout(timeout, send::send_request(dest, request)) + let client = &services().globals.client.federation; + let response = tokio::time::timeout(timeout, send::send_request(client, dest, request)) .await .map_err(|_| { warn!("Timeout after 300 seconds waiting for server response of {dest}"); @@ -781,8 +782,9 @@ async fn handle_events_kind_normal( } let permit = services().sending.maximum_requests.acquire().await; - + let client = &services().globals.client.sender; let response = send::send_request( + client, dest, send_transaction_message::v1::Request { origin: services().globals.server_name().to_owned(), diff --git a/src/service/sending/send.rs b/src/service/sending/send.rs index a415a3d675ced91d3cdca33d61b02b255104ad68..ebd01570365431ecc4ff7fd320edb97abfd70f1e 100644 --- a/src/service/sending/send.rs +++ b/src/service/sending/send.rs @@ -44,7 +44,9 @@ pub enum FedDest { } #[tracing::instrument(skip_all, name = "send")] -pub(crate) async fn send_request<T>(destination: &ServerName, request: T) -> Result<T::IncomingResponse> +pub(crate) async fn send_request<T>( + client: &reqwest::Client, destination: &ServerName, request: T, +) -> Result<T::IncomingResponse> where T: OutgoingRequest + Debug, { @@ -202,12 +204,7 @@ pub(crate) async fn send_request<T>(destination: &ServerName, request: T) -> Res } debug!("Sending request to {destination} at {url}"); - let response = services() - .globals - .client - .federation - .execute(reqwest_request) - .await; + let response = client.execute(reqwest_request).await; debug!("Received response from {destination} at {url}"); match response {