Skip to content

Commit c9e61c6

Browse files
authored
Merge pull request #100 from utopia-php/feat-connect-timeout
feat: connect timeout
2 parents 5d12452 + 957d3f3 commit c9e61c6

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/Utopia/Messaging/Adapter.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ protected function request(
7878
string $method,
7979
string $url,
8080
array $headers = [],
81-
array $body = null,
82-
int $timeout = 30
81+
?array $body = null,
82+
int $timeout = 30,
83+
int $connectTimeout = 10
8384
): array {
8485
$ch = \curl_init();
8586

@@ -109,6 +110,7 @@ protected function request(
109110
CURLOPT_RETURNTRANSFER => true,
110111
CURLOPT_USERAGENT => "Appwrite {$this->getName()} Message Sender",
111112
CURLOPT_TIMEOUT => $timeout,
113+
CURLOPT_CONNECTTIMEOUT => $connectTimeout,
112114
]);
113115

114116
$response = \curl_exec($ch);
@@ -150,7 +152,8 @@ protected function requestMulti(
150152
array $urls,
151153
array $headers = [],
152154
array $bodies = [],
153-
int $timeout = 30
155+
int $timeout = 30,
156+
int $connectTimeout = 10
154157
): array {
155158
if (empty($urls)) {
156159
throw new \Exception('No URLs provided. Must provide at least one URL.');
@@ -187,6 +190,7 @@ protected function requestMulti(
187190
CURLOPT_FORBID_REUSE => false,
188191
CURLOPT_FRESH_CONNECT => false,
189192
CURLOPT_TIMEOUT => $timeout,
193+
CURLOPT_CONNECTTIMEOUT => $connectTimeout,
190194
]);
191195

192196
$urlCount = \count($urls);

0 commit comments

Comments
 (0)