diff --git a/src/Protocols/Pusher/MetricsHandler.php b/src/Protocols/Pusher/MetricsHandler.php index 18485a06..a2cf7ee0 100644 --- a/src/Protocols/Pusher/MetricsHandler.php +++ b/src/Protocols/Pusher/MetricsHandler.php @@ -141,12 +141,15 @@ protected function gatherMetricsFromSubscribers(Application $application, string */ protected function requestMetricsFromSubscribers(Application $application, string $key, string $type, ?array $options): void { + dump('Requesting metrics from subscribers using '.$key); + $this->pubSubProvider->publish([ 'type' => 'metrics', 'key' => $key, 'application' => serialize($application), 'payload' => ['type' => $type, 'options' => $options], ])->then(function ($total) { + dump('Total subscribers: '.$total); $this->subscribers = $total; }); } @@ -211,6 +214,7 @@ protected function listenForMetrics(string $key): Deferred $deferred = new Deferred; $this->pubSubProvider->on('metrics-retrieved', function ($payload) use ($key, $deferred) { + dump('Metrics received for '.$key); if ($payload['key'] !== $key) { return; } diff --git a/src/Servers/Reverb/Publishing/RedisPubSubProvider.php b/src/Servers/Reverb/Publishing/RedisPubSubProvider.php index 6b97909a..5721e5ed 100644 --- a/src/Servers/Reverb/Publishing/RedisPubSubProvider.php +++ b/src/Servers/Reverb/Publishing/RedisPubSubProvider.php @@ -51,12 +51,11 @@ public function subscribe(): void { $this->ensureConnected(); - $this->subscribingClient->subscribe($this->channel) - ->then(function () { - $this->subscribingClient->on('message', function (string $channel, string $payload) { - $this->messageHandler->handle($payload); - }); - }); + $this->subscribingClient->subscribe($this->channel); + + $this->subscribingClient->on('message', function (string $channel, string $payload) { + $this->messageHandler->handle($payload); + }); } /** @@ -65,6 +64,7 @@ public function subscribe(): void public function on(string $event, callable $callback): void { $this->subscribingClient->on('message', function (string $channel, string $payload) use ($event, $callback) { + dump($payload); $payload = json_decode($payload, associative: true, flags: JSON_THROW_ON_ERROR); if (($payload['type'] ?? null) === $event) { diff --git a/tests/ReverbTestCase.php b/tests/ReverbTestCase.php index f29d6042..e7d76e50 100644 --- a/tests/ReverbTestCase.php +++ b/tests/ReverbTestCase.php @@ -105,7 +105,7 @@ protected function resetFiber(): void */ public function stopServer(): void { - rescue(fn () => app(PubSubProvider::class)->disconnect()); + app(PubSubProvider::class)->disconnect(); if ($this->server) {