diff --git a/src/Client/SwooleClient.php b/src/Client/SwooleClient.php index d3cba45..6b1bee4 100644 --- a/src/Client/SwooleClient.php +++ b/src/Client/SwooleClient.php @@ -56,6 +56,10 @@ public function connect(): void public function close(): bool { $this->connected = false; + foreach ($this->recvChannels as $channel) { + $channel->close(); + } + $this->recvChannels = []; return $this->socket->close(); diff --git a/src/Consumer/Consumer.php b/src/Consumer/Consumer.php index 66d20f7..ec4d028 100644 --- a/src/Consumer/Consumer.php +++ b/src/Consumer/Consumer.php @@ -297,6 +297,10 @@ protected function fetchMessages(): void } $nodeId = key($this->fetchOptions); next($this->fetchOptions); + if (empty($this->fetchOptions)) { + // avoid dead cycle. + sleep(1); + } if (!$currentList) { return; }