Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onEntry not getting hit #31

Open
laclance opened this issue Dec 6, 2018 · 4 comments
Open

onEntry not getting hit #31

laclance opened this issue Dec 6, 2018 · 4 comments

Comments

@laclance
Copy link

laclance commented Dec 6, 2018

Hi I followed the setup instructions but my onEntry function is not getting hit and I can see my event in my log file:
zmq.publish {"channel":"import-export","payload":"{\"event\":\"Fastacademy\\\\AwezaTMS\\\\Events\\\\ProgressUpdated\",\"payload\":{\"row_num\":100,\"socket\":null}}"}

RatchetServer

<?php

namespace Fastacademy\AwezaTMS;

use Askedio\LaravelRatchet\RatchetWsServer;

class RatchetServer extends RatchetWsServer
{
    public function onEntry($messages) {
        \Log::debug('hello');
        \Log::debug($messages);
    }
}

ratchet.php

    'class'           => \Fastacademy\AwezaTMS\RatchetServer::class,
    'host'            => '0.0.0.0', // Prepend tls:// to host address to enable SSL/TLS. Example: tls://0.0.0.0
    'port'            => '8080',
    'connectionLimit' => false,
    'throttle'        => [
        'onOpen'    => '5:1',
        'onMessage' => '20:1',
     ],
    'abortOnMessageThrottle' => false,
    'blackList'              => [],
    'zmq'                    => [
        'host'   => '127.0.0.1',
        'port'   => 5555,
        'method' => \ZMQ::SOCKET_PULL,
    ],

zmq.php

 'default' => 'publish',
    'connections' => [
        'publish' => [
            'dsn'       => 'tcp://127.0.0.1:5555',
            'method'    => \ZMQ::SOCKET_PUB,
        ],
        'subscribe' => [
            'dsn'    => 'tcp://0.0.0.0:5555',
            'method'    => \ZMQ::SOCKET_SUB,
        ],
    ]
@simonhamp
Copy link
Collaborator

@laclance In your config/ratchet.php can you try changing the zmq.method option to match the type used for your config/zmq.php connections.subscribe.method, i.e. in config/ratchet.php

    'zmq'                    => [
        'host'   => '127.0.0.1',
        'port'   => 5555,
        'method' => \ZMQ::SOCKET_SUB,
    ],

Please let me know how you get on.

@pablor21
Copy link

pablor21 commented Jan 10, 2019

Hi @simonhamp! I'm having the same problem, here is my config:

.env
BROADCAST_DRIVER=zmq

config/boradcasting.php

'zmq' => [
            'driver' => 'zmq',
        ],

rconfig/atchet.php

'class'           => \App\Websockets\TestWs::class,
    'host'            => '0.0.0.0',
    'port'            => '8080',
    'connectionLimit' => false,
    'throttle'        => [
        'onOpen'    => '5000:1',
        'onMessage' => '20000:1',
     ],
    'abortOnMessageThrottle' => false,
    'blackList'              => [],
    'zmq'                    => [
        'host'   => '127.0.0.1',
        'port'   => 5555,
        'method' => \ZMQ::SOCKET_SUB,
    ],

config/zmq.php

return [
    'default' => 'publish',

    'connections' => [

        'publish' => [
            'dsn'       => 'tcp://127.0.0.1:5555',
            'method'    => \ZMQ::SOCKET_PUB,
        ],

        'subscribe' => [
            'dsn'    => 'tcp://0.0.0.0:5555',
            'method'    => \ZMQ::SOCKET_SUB,
        ],

    ]
];

@pablor21
Copy link

Hey! I think I've found the solution! Just use

\ZMQ::SOCKET_PUSH and \ZMQ::SOCKET_PULL instead of \ZMQ::SOCKET_PUB and \ZMQ::SOCKET_SUB on your zmq config.

Also make sure that your zmq method is \ZMQ::SOCKET_PULL on config/ratchet.php

@simonhamp
Copy link
Collaborator

simonhamp commented Jan 23, 2019

Ah I think I’ve bumped into that before too. I think it’s some config of ZMQ but I haven’t had chance to dig into it.

So for now it’s best to use PUSH and PULL instead of PUB/SUB.

Thanks for looping back with your solution @pablor21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants