zeromq / php-zmq

ZeroMQ for PHP
http://pecl.php.net/zmq
Other
553 stars 119 forks source link

Cannot SOCKET_PUSH from browser, although everything working fine from command line #197

Open tafelnl opened 5 years ago

tafelnl commented 5 years ago

I have the following code:

socket.php:

$loop   = React\EventLoop\Factory::create();
$pusher = new \Pusher;

$context = new React\ZMQ\Context($loop);
$pull = $context->getSocket(ZMQ::SOCKET_PULL);
$pull->bind('tcp://0.0.0.0:5555');
$pull->on('message', array($pusher, 'someFunction'));

//following code made possible by Ratchet
//URL: http://socketo.me/docs/push#tying_it_together
$webSock = new React\Socket\Server('0.0.0.0:8080', $loop);
$webServer = new Ratchet\Server\IoServer(
    new Ratchet\Http\HttpServer(
        new Ratchet\WebSocket\WsServer(
            new Ratchet\Wamp\WampServer(
                $pusher
            )
        )
    ),
    $webSock
);

$loop->run();

pusher.php:

$context = new ZMQContext();

$socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
$socket->connect("tcp://mydomain.com:5555");

$socket->send('someString);

Both work fine from the command line, and I can also actually send out and receive data.

But whenever I try to execute the pusher.php from the browser (something that has to work in the production version eventually) nothing happens.

Does anyone know what may be causing this? All ports etc are opened up as far as I know.

md-riaz commented 11 months ago

I also stuck in the same situation.