You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
using the code bellow when I restart redis server the script terminates without calling close or error event.
$loop = \React\EventLoop\Loop::get();
$factory = newFactory($loop, new \React\Socket\Connector($loop));
$client = $factory->createLazyClient($conStr);
$client->on('message', function ($channel, $message) {
$message = (object)unserialize(gzuncompress($message));
echodate("Ymd H:i:s")." => ".$message->text.PHP_EOL;
});
$client->on('error', function (\Exception$e) {
echo$e->getMessage().PHP_EOL;
});
$client->on('close', function () {
echo"CLOSED".PHP_EOL;
});
$this->subscribeChannel($client, "pubsub_teste");
combining reactphp-redis with ratchet socket server adding the code bellow and using the same loop, when I restart redis server, the script continues to run undefinetly but no more messages are received.
@jupitern Thanks for bringing this up, excellent question!
In the current version, the lazy client is responsible for re-establishing the connection when needed, so a close event will only be emitted when the connection is ultimately closed by calling close().
However, the lazy client will automatically emit the unsubscribe/punsubscribe event when the connection is lost. This can be used to automatically re-subscribe to any channels:
$redis->on('unsubscribe', function ($channel, $total) {
// unsubscribed from given $channel
});
There are plans to revisit the API via #118. In the future, we will likely use a simpler RedisClient API that will simply emit open and close events throughout its lifetime.
I hope this helps! 👍 If so, consider supporting this project, e.g. by becoming a sponsor ❤️
Hi,
using the code bellow when I restart redis server the script terminates without calling close or error event.
combining reactphp-redis with ratchet socket server adding the code bellow and using the same loop, when I restart redis server, the script continues to run undefinetly but no more messages are received.
can you help understand what to change to be able to reconnect to redis server.
thanks
The text was updated successfully, but these errors were encountered: