gpt4 book ai didi

网络套接字 : Are Rachet & autobahn from npm compatible?

转载 作者:行者123 更新时间:2023-12-04 16:13:07 27 4
gpt4 key购买 nike

我正在试验 Ratchet php library .特别是,我一直在尝试整合他们的 push integration演示到 React 应用程序中。

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

但是,当我尝试使用 autobahn JS from npm 时一切都融化了。这似乎实现了较新版本的 Web Sockets 协议(protocol)?

高速公路一次性通行证wampSec-WebSocket-Protocol header ,Ratchet 似乎支持。高速公路的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 协议(protocol),或者有没有办法让这两个库成功通信?

最佳答案

根据 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.

关于网络套接字 : Are Rachet & autobahn from npm compatible?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48818453/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com