fixed warm cache

This commit is contained in:
2026-10-29 10:23:45 +01:00
parent 9bc9a8a2dc
commit 3857efcf84
3 changed files with 31 additions and 2 deletions
@@ -55,6 +55,7 @@ class VisualLimsApiClient
]);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$this->applyTimeouts($ch);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$log = fopen(__DIR__ . '/curl_auth_debug.log', 'a') ?: fopen('php://stderr', 'w');
curl_setopt($ch, CURLOPT_STDERR, $log);
@@ -91,6 +92,19 @@ class VisualLimsApiClient
}
}
/**
* Timeout di rete: evita che una richiesta resti appesa all'infinito
* se il gestionale smette di rispondere (connessione "morta").
* $idleSeconds = secondi senza trasferire dati prima di abbandonare.
*/
private function applyTimeouts($ch, $idleSeconds = 120)
{
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt($ch, CURLOPT_TCP_KEEPALIVE, 1);
curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1);
curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $idleSeconds);
}
private function getToken()
{
if ($this->token === null) {
@@ -113,6 +127,7 @@ class VisualLimsApiClient
]);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$this->applyTimeouts($ch);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$log = fopen(__DIR__ . '/curl_request_debug.log', 'w') ?: fopen('php://stderr', 'w');
curl_setopt($ch, CURLOPT_STDERR, $log);
@@ -156,6 +171,7 @@ class VisualLimsApiClient
]);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$this->applyTimeouts($ch, 300);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
@@ -190,6 +206,7 @@ class VisualLimsApiClient
]);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$this->applyTimeouts($ch, 300);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
@@ -239,8 +256,9 @@ class VisualLimsApiClient
]);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$this->applyTimeouts($ch, 300);
$response = curl_exec($ch);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curl_error = curl_error($ch);
curl_close($ch);
@@ -280,6 +298,7 @@ class VisualLimsApiClient
]);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$this->applyTimeouts($ch, 300);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);