From ae8320e4fed3ed8f716a12f3c7f7b08f93aa9f53 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 4 Jun 2021 12:53:18 +0200 Subject: [PATCH] fix(realtime): undefined projectId for shared stats --- app/controllers/api/health.php | 1 - app/realtime.php | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index 0885c0c40b..dd1d4a0d69 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -6,7 +6,6 @@ use Utopia\Storage\Device\Local; use Utopia\Storage\Storage; use Appwrite\ClamAV\Network; use Appwrite\Event\Event; -use RuntimeException; App::get('/v1/health') ->desc('Get HTTP') diff --git a/app/realtime.php b/app/realtime.php index e480c385ed..013b183d05 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -324,7 +324,9 @@ $server->on('message', function (Server $server, Frame $frame) { }); $server->on('close', function (Server $server, int $connection) use (&$connections, &$subscriptions, &$stats) { - $stats->decr($connections[$connection]['projectId'], 'connectionsTotal'); + if (array_key_exists($connection, $connections)) { + $stats->decr($connections[$connection]['projectId'], 'connectionsTotal'); + } Realtime::unsubscribe($connection, $subscriptions, $connections); Console::info('Connection close: ' . $connection); });