Skip to content

Commit 48ea89a

Browse files
feat: add curl options to prevent stuck connections
Add three curl options to the Guzzle client to prevent connections from getting stuck indefinitely: 1. Low-speed stall guard (CURLOPT_LOW_SPEED_LIMIT + CURLOPT_LOW_SPEED_TIME): Fails requests if transfer speed drops below 1 byte/sec for 120 seconds 2. Disable connection reuse (CURLOPT_FORBID_REUSE + CURLOPT_FRESH_CONNECT): Prevents reusing stale keep-alive connections that may be half-closed 3. TCP keepalive (CURLOPT_TCP_KEEPALIVE + CURLOPT_TCP_KEEPIDLE + CURLOPT_TCP_KEEPINTVL): Enables TCP-level keepalive to detect dead connections Co-Authored-By: ondrej.hlavacek@keboola.com <ondrej.hlavacek@keboola.com>
1 parent 9d28473 commit 48ea89a

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/Keboola/StorageApi/Client.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,15 @@ private function initClient(array $config)
213213
'base_uri' => $this->apiUrl,
214214
'handler' => $handlerStack,
215215
'connect_timeout' => RequestTimeoutMiddleware::REQUEST_TIMEOUT_DEFAULT,
216+
'curl' => [
217+
CURLOPT_LOW_SPEED_LIMIT => 1,
218+
CURLOPT_LOW_SPEED_TIME => 120,
219+
CURLOPT_FORBID_REUSE => true,
220+
CURLOPT_FRESH_CONNECT => true,
221+
CURLOPT_TCP_KEEPALIVE => 1,
222+
CURLOPT_TCP_KEEPIDLE => 60,
223+
CURLOPT_TCP_KEEPINTVL => 30,
224+
],
216225
]);
217226
}
218227

0 commit comments

Comments
 (0)