I got a problem when trying to use React\ZMQ on windows 10 and php7.2. I do some research, and evaluate the way how I install ZMQ extension on apache, but there is nothing wrong.
The problem is the socket does not push anything if accessed from the browser and does not give any error log, but working fine from CMD
but the same code is working fine on Linux though CLI and browser.
On Linux, I did not change anything just install php_zmq and so is Windows.
there are many similar questions but it doesn't give me a solution, I have added the php_zmq.dll
to php.ini, store the php_zmq.dll
in php/ext
directory, and store the libzmq.dll
on php
directory and I have checked to the phpinfo and ZMQ extension is loaded smoothly.
here is the code
//push.php
<?php
require './vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$context = new React\ZMQ\Context($loop);
$push = $context->getSocket(ZMQ::SOCKET_PUSH);
$status = $push->connect('tcp://127.0.0.1:5555');
$push->send("test");
$loop->run();
?>
//pull-server.php
<?php
require 'vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$context = new React\ZMQ\Context($loop);
$pull = $context->getSocket(ZMQ::SOCKET_PULL);
$pull->bind('tcp://127.0.0.1:5555');
$pull->on('error', function ($e) {
var_dump($e->getMessage());
});
$pull->on('message', function ($msg) {
echo "Received: $msg
";
});
$loop->run();
?>
what I expected from this is when pull-server.php is run from CMD (php pull-server.php) and push.php is accessed from the browser (eg:localhost/project/push.php) then push some data to pull-server.php in CMD.