“这台服务器只会说WebSocket子协议wamp.2”

时间:2017-10-31 02:59:44

标签: php laravel websocket ratchet

我正在尝试订阅api的频道。我尝试使用'ratchetphp / Pawl'和Laravel,这是我的代码:

    $loop = Factory::create();
    $connector = new Connector($loop);

    $connector('wss://api.poloniex.com')
        ->then(function(WebSocket $conn) {
            $conn->send('{"event": "subscribe","channel":"ticker","pair": "BTC_ETH"}');

            $conn->on('message', function(MessageInterface $msg) use ($conn) {
                var_dump($msg);
            });
        }, function(\Exception $e) use ($loop) {
            /** hard error */
            echo "Could not connect: {$e->getMessage()}\n";
            $loop->stop();
        });

    $loop->run();

但是,我收到错误:

  

此服务器只能说WebSocket子协议wamp.2.cbor.batched,wamp.2.cbor,wamp.2.msgpack.batched,wamp.2.msgpack,wamp.2.json.batched,wamp.2.json

我还尝试了$connector('wss://api.poloniex.com', ['wamp'])$connector('wss://api.poloniex.com', ['wamp2']),但同样的错误仍然存​​在。

我做错了什么?

0 个答案:

没有答案