在子域上没有连接的zmq棘轮

时间:2016-10-25 09:16:20

标签: sockets websocket ratchet php-socket

我正在尝试在子域上运行棘轮..我已经创建棘轮服务器,如Ratchet push集成中所述并将其上传到subdomain.domain.com我的子域也在同一台服务器上 我的项目是在主要领域的laravel。(www.domain.com)

这是我在子域

上的聊天室代码
<?php
    require dirname(__DIR__) . '/vendor/autoload.php';
    $loop   = React\EventLoop\Factory::create();
    $pusher = new MyApp\Pusher;

    //Listen for the web server to make a ZeroMQ push after an ajax request
    $context = new React\ZMQ\Context($loop);
    $pull = $context->getSocket(ZMQ::SOCKET_PULL);
    $pull->bind('tcp://subdomain.domain.com:5555'); //Binding to 27.0.0.1 means the only client that can connect is itself
    $pull->on('message', array($pusher, 'onBookingSeats'));

    //Set up our WebSocket server for clients wanting real-time updates
    $webSock = new React\Socket\Server($loop);
    $webSock->Listen(80,'0.0.0.0'); // Binding to 0.0.0.0 means remotes can connect
    $webSock = new Ratchet\Server\IoServer(
        new Ratchet\Http\HttpServer(
            new Ratchet\WebSocket\WsServer(
                new Ratchet\Wamp\WampServer(
                    $pusher
                    )
                )
            ),
        $webSock
        );

    $loop->run();
?>

我的控制器代码,我将请求发送到www.domain.com上的socket

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

    $socket->send(json_encode($seats));
    return Redirect::to('booking/payment');

并在www.domain.com上的js文件中接收websocket请求

var conn = new ab.Session('ws://rtime.ticketpk.com:80',
    function() {
        conn.subscribe('kittensCategory', function(topic, data) {
            // This is where you would add the new article to the DOM (beyond the scope of this tutorial)
            console.log('New article published to category "' + topic + '" : ' + data.title);
        });
    },
    function() {
        console.warn('WebSocket connection closed');
    },
    {'skipSubprotocolCheck': true}
);

我认为我在使用websockets进行绑定时遇到了问题

0 个答案:

没有答案