React \ ZMQ \ Context事件无法在Windows上触发的问题

时间:2019-02-17 23:51:17

标签: php websocket ratchet reactphp

基本上没有React \ ZMQ \ Context事件触发,我也不知道为什么会发生这种情况,我想知道是否有人可以帮助我解决我的问题。

我尝试更改tcp连接的端口,但所有端口均不起作用。

// ajax file
add_post.php
$context = new ZMQContext();
$socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
$socket->connect('tcp://127.0.0.1:5555');
$socket->send(json_encode($data));

// push_server.php  
$loop = \React\EventLoop\Factory::create();


$pusher = new \App\Pusher();
$context = new \React\ZMQ\Context($loop);


$pull = $context->getSocket(ZMQ::SOCKET_PULL);
$pull->bind('tcp://127.0.0.1:5555');
$pull->on( 'open',    function( $msg ){ echo "open";    } );
$pull->on( 'close',   function( $msg ){ echo "close";   } );
$pull->on( 'message', function( $msg ){ echo "message"; } );
$pull->on( 'error',   function( $msg ){ echo "error";   } );
$webSock = new \React\Socket\Server('127.0.0.1:8000', $loop);

$webServer = new \Ratchet\Server\IoServer(
 new \Ratchet\Http\HttpServer(
     new \Ratchet\WebSocket\WsServer(
         new \Ratchet\Wamp\WampServer(
             $pusher
         )
     )
 ),
 $webSock
  );


 $loop->run();

 // client.html
 let conn = new ab.Session('ws://127.0.0.1:8000', function () {
        conn.subscribe('onData', function (topic, data) {
            console.log({topic, data})
        })
    });

我想知道为什么事件永远不会触发

0 个答案:

没有答案