From 8d1369ee0248879196cfb81d29c8441ffa9aaf7b Mon Sep 17 00:00:00 2001 From: Alex Renoki Date: Mon, 7 Dec 2020 23:15:09 +0200 Subject: [PATCH] Fixed peak connections count not being able to settle down --- src/Statistics/Collectors/RedisCollector.php | 2 +- src/Statistics/Statistic.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Statistics/Collectors/RedisCollector.php b/src/Statistics/Collectors/RedisCollector.php index 050eb74..a7bd00f 100644 --- a/src/Statistics/Collectors/RedisCollector.php +++ b/src/Statistics/Collectors/RedisCollector.php @@ -249,7 +249,7 @@ class RedisCollector extends MemoryCollector $this->channelManager->getPublishClient()->hset( $this->channelManager->getRedisKey($appId, null, ['stats']), - 'peak_connections_count', $currentConnectionCount + 'peak_connections_count', max(0, $currentConnectionCount) ); $this->channelManager->getPublishClient()->hset( diff --git a/src/Statistics/Statistic.php b/src/Statistics/Statistic.php index 1a92488..5e1f05f 100644 --- a/src/Statistics/Statistic.php +++ b/src/Statistics/Statistic.php @@ -178,7 +178,7 @@ class Statistic public function reset(int $currentConnectionsCount) { $this->currentConnectionsCount = $currentConnectionsCount; - $this->peakConnectionsCount = $currentConnectionsCount; + $this->peakConnectionsCount = max(0, $currentConnectionsCount); $this->webSocketMessagesCount = 0; $this->apiMessagesCount = 0; }