[FIX] simulate-nis2.php: SSE heartbeat ogni 25s + Apache Timeout 1800

- SSE heartbeat (commento ': heartbeat') ogni 25s in simLog() per mantenere
  viva la connessione attraverso proxy/CDN con timeout 300s (pattern lg231)
- Apache vhost: Timeout 1800 + ProxyTimeout 1800 (su Hetzner direttamente)
  per simulazioni che richiedono 8-12 minuti

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
DevEnv nis2-agile 2026-03-10 10:28:28 +01:00
parent 527446f4e3
commit 459d2bc8cd

View File

@ -85,6 +85,7 @@ $S = [
function simLog(string $msg, string $type = 'info'): void
{
static $lastHeartbeat = 0;
$ts = date('H:i:s');
if (IS_CLI) {
$prefix = [
@ -99,6 +100,12 @@ function simLog(string $msg, string $type = 'info'): void
echo "[$ts] {$prefix} {$msg}\n";
flush();
} else {
// Heartbeat SSE ogni 25s — mantiene viva la connessione attraverso proxy (pattern lg231)
$now = time();
if ($now - $lastHeartbeat >= 25) {
echo ": heartbeat " . $ts . "\n\n";
$lastHeartbeat = $now;
}
echo 'data: ' . json_encode(['t' => $type, 'm' => "[$ts] $msg"]) . "\n\n";
flush();
}