PHP Thruway + Authobahn.js = 426,如何使用带有pub / sub的websockets?

时间:2018-05-23 01:05:44

标签: php websocket autobahn wamp-protocol thruway

我正在尝试使用websockets主要用于在事件上将数据从服务器推送到客户端。

所以,我在本地配置ThruwayAutobahn.js两次:由我自己并在this tutorial的帮助下。

服务器正确启动:

./bin/console thruway:router:start
Making a go at starting the Thruway Router
2018-05-23T00:29:33.6760270 debug      [Thruway\Peer\Router 17047] New router created
2018-05-23T00:29:33.6830490 info       [Thruway\Peer\Router 17047] Starting router
2018-05-23T00:29:33.6853010 info       [Thruway\Transport\RatchetTransportProvider 17047] Websocket listening on 127.0.0.1:9998
2018-05-23T00:29:33.6864550 info       [Thruway\Transport\RatchetTransportProvider 17047] Websocket listening on 127.0.0.1:9999
2018-05-23T00:29:33.6865040 info       [Thruway\Peer\Router 17047] Starting loop

浏览器代码非常简单:

var connection = new autobahn.Connection({
    url: 'ws://127.0.0.1:9999/',
    realm: 'realm1'
});
connection.onopen = function (session, details) {
    console.info('Connection opened: ' + session + ' | ' + details);
};
connection.onclose = function (reason, details) {
    console.info('Connection closed: ' + reason + ' | ' + details);
};
connection.open();

但我在浏览器(Safari,Chrome,FireFox)中看到错误426 No Sec-WebSocket-Protocols requested supported

经过一些谷歌搜索,我发现只有非常古老的问题/答案(2014年至2016年),人们说Authobahn.js使用WAMPv2但Ratchet只使用WAMPv1 ..但我看到WAMPv2在2017-2018由Thruway图书馆支持

我的问题很简单:如何使这项工作?或者,也许,使用angularWAMP?感谢任何例子,谢谢。

版本:

~ composer show -D
sensio/distribution-bundle     v5.0.21  Base bundle for Symfony Distributions
sensio/framework-extra-bundle  v5.1.6   This bundle provides a way to configure your controllers with annotations
sensio/generator-bundle        v3.1.7   This bundle generates code for you
symfony/monolog-bundle         v3.2.0   Symfony MonologBundle
symfony/phpunit-bridge         v4.0.9   Symfony PHPUnit Bridge
symfony/polyfill-apcu          v1.8.0   Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/swiftmailer-bundle     v3.2.2   Symfony SwiftmailerBundle
symfony/symfony                v3.4.9   The Symfony PHP framework
thruway/pawl-transport         0.5.0    Pawl WebSocket Transport for Thruway Client
voryx/thruway-bundle           0.3.1    WebSockets (WAMP2) integration for Symfony2

高速公路是18.3.2

0 个答案:

没有答案