Websockets:npm 的 Rachet 和高速公路是否兼容?

Websockets: Are Rachet & autobahn from npm compatible?

我正在尝试将 Ratchet php library. In particular, I've been trying to integrate their push integration 演示放入 React 应用程序。

他们的演示引用 a seemingly one-off version of the autobahn JS library,这对我的服务器实现不利(他们的演示几乎是重复的)。

然而,当我尝试使用 autobahn JS from npm 时,一切都崩溃了。这似乎实现了更新版本的 Web 套接字协议?

one-off 版本的高速公路通过 wampSec-WebSocket-Protocol header,棘轮似乎支持。 autobahn 的 npm 版本通过 wamp.2.json, wamp.2.msgpack...

深​​入研究我发现的 Ratchet 代码 this

If any component in a stack supports a WebSocket sub-protocol return each supported in an array

所以我在我的组件上实现了 Ratchet\WebSocket\WsServerInterface

public function getSubProtocols()
{
    return ['wamp.2.json', 'wamp.2.msgpack'];
}

现在连接尝试更进一步了,但仍然失败了

failing transport due to protocol violation: unexpected message type 0

然后客户端关闭连接失败

Uncaught DOMException: Failed to execute 'close' on 'WebSocket': The code must be either 1000, or between 3000 and 4999. 1002 is neither.

这是怎么回事; Ratchet 是否支持旧版本的 Web Socket 协议,或者有没有办法让这两个库成功对话?

这两个库不兼容,根据 this issue on GitHub

Autobahn 0.9+ implements wampv2, we have to use autobahn 0.8, and I also don't find it on npm. Instead I find wamp1, but I haven't tested it yet.