voryx / Thruway

PHP Client and Router Library for Autobahn and WAMP (Web Application Messaging Protocol) for Real-Time Application Messaging
MIT License
676 stars 117 forks source link

CPU 100% :( #319

Closed manues closed 4 years ago

manues commented 5 years ago

Hi guys! I've been using your library since November and it works like a charm. But here is my problem: time to time my pub-sub script begins to use 100% of CPU and I don't know why. Is there a way to display current count of connections or so? Usually it happens on 5-7 days after running.

My script look pretty small:

$loop = \React\EventLoop\Factory::create();
$pusher = new \Thruway\Peer\Client("wamp.pubsub", $loop);

$pusher->on('open', function ($session) use ($loop) {
    $context = new React\ZMQ\Context($loop);
    $pull = $context->getSocket(ZMQ::SOCKET_PULL);
    $pull->bind('tcp://127.0.0.1:5555');

    $pull->on('message', function ($entry) use ($session) {
        $entryData = json_decode($entry, true);
        $channel = strtolower("{$entryData['event']}.{$entryData['channel']}");

        if (isset($channel)) {
            $session->publish($channel, $entryData['data']);
        }
    });
});

$router = new Thruway\Peer\Router($loop);
$router->addInternalClient($pusher);
$router->addTransportProvider(new Thruway\Transport\RatchetTransportProvider("0.0.0.0", 42111));
$router->start();
mbonneau commented 5 years ago

I don't see anything right away that would be causing issues.

Could you provide a little more background? PHP version, number of clients, etc.

mbonneau commented 4 years ago

Closing for inactivity