From 957d3f35811f150ecc236631a8dd522b7637fe3a Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Mon, 21 Jul 2025 12:47:27 +0100 Subject: [PATCH] feat: connect timeout --- src/Utopia/Messaging/Adapter.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Utopia/Messaging/Adapter.php b/src/Utopia/Messaging/Adapter.php index 250fbf3..e58a69f 100644 --- a/src/Utopia/Messaging/Adapter.php +++ b/src/Utopia/Messaging/Adapter.php @@ -78,8 +78,9 @@ protected function request( string $method, string $url, array $headers = [], - array $body = null, - int $timeout = 30 + ?array $body = null, + int $timeout = 30, + int $connectTimeout = 10 ): array { $ch = \curl_init(); @@ -109,6 +110,7 @@ protected function request( CURLOPT_RETURNTRANSFER => true, CURLOPT_USERAGENT => "Appwrite {$this->getName()} Message Sender", CURLOPT_TIMEOUT => $timeout, + CURLOPT_CONNECTTIMEOUT => $connectTimeout, ]); $response = \curl_exec($ch); @@ -149,7 +151,8 @@ protected function requestMulti( array $urls, array $headers = [], array $bodies = [], - int $timeout = 30 + int $timeout = 30, + int $connectTimeout = 10 ): array { if (empty($urls)) { throw new \Exception('No URLs provided. Must provide at least one URL.'); @@ -186,6 +189,7 @@ protected function requestMulti( CURLOPT_FORBID_REUSE => false, CURLOPT_FRESH_CONNECT => false, CURLOPT_TIMEOUT => $timeout, + CURLOPT_CONNECTTIMEOUT => $connectTimeout, ]); $urlCount = \count($urls);