dtrgqjcd877528 2018-05-23 01:05
浏览 71

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

I'm trying to use websockets mainly for pushing data from server to client on events.

So, i configured locally Thruway and Autobahn.js twice: by myself and with help of this tutorial.

Server starts correctly:

./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

Browser code is very simple:

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();

But i see error 426 No Sec-WebSocket-Protocols requested supported in browsers (Safari, Chrome, FireFox).

After some googling, i found only very old questions/answers (2014..2016) where people says that Authobahn.js use WAMPv2 but Ratchet only WAMPv1.. but i see that WAMPv2 is supported by Thruway library in 2017-2018.

My question is simple: how to make this work? Or, maybe, with angularWAMP? Any examples are appreciated, thanks.


Versions:

~ 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

Autobahn is 18.3.2

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥15 stable diffusion
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿