gpt4 book ai didi

android - 高速公路异常 WebSockets 协议(protocol)违规

转载 作者:行者123 更新时间:2023-11-30 03:09:56 24 4
gpt4 key购买 nike

在我的 android 应用程序中,我想使用高速公路库来使用 websockets。

我认为服务器正在使用 draft-17。谁能告诉我如何设置客户端以使用此协议(protocol)?

我有这个代码:

      mConnection.connect(url,new String[] {"protocolname?"}, new WebSocketHandler() {

//some functions
},options);

问候

更新在我的服务器上,我使用 8.1 版的 Jetty。

更新LogCat 的输出是:

01-15 22:54:53.481: D/de.tavendo.autobahn.WebSocketReader(32452): created
01-15 22:54:53.491: D/de.tavendo.autobahn.WebSocketConnection(32452): WS reader created and started
01-15 22:54:53.491: D/de.tavendo.autobahn.WebSocketReader(32452): running
01-15 22:54:53.491: D/de.tavendo.autobahn.WebSocketWriter(32452): created
01-15 22:54:53.491: D/de.tavendo.autobahn.WebSocketConnection(32452): WS writer created and started
01-15 22:54:53.551: D/de.tavendo.autobahn.WebSocketConnection(32452): opening handshake received
01-15 22:54:53.551: D/Websocket(32452): Status: Connected to ws://192.168.178.30:8080
01-15 22:54:53.551: D/de.tavendo.autobahn.WebSocketReader(32452): run() : WebSocketException (de.tavendo.autobahn.WebSocketException: RSV != 0 and no extension negotiated)
01-15 22:54:53.551: D/de.tavendo.autobahn.WebSocketReader(32452): ended
01-15 22:54:53.551: D/de.tavendo.autobahn.WebSocketConnection(32452): fail connection [code = 4, reason = WebSockets protocol violation
01-15 22:54:53.551: D/de.tavendo.autobahn.WebSocketReader(32452): quit
01-15 22:54:53.551: D/de.tavendo.autobahn.WebSocketWriter(32452): ended
01-15 22:54:53.551: D/Websocket(32452): Connection lost.
01-15 22:54:53.551: D/de.tavendo.autobahn.WebSocketConnection(32452): worker threads stopped

最佳答案

您指的是 WebSocket 协议(protocol)版本还是 WebSocket 子协议(protocol)?

关于前者:AutobahnAndroid 实现了 RFC6455(最后也是最终的 WebSocket 协议(protocol)版本)。没有办法降级到旧版本,但基本上,从 Hybi-10+ 到 RFC6455 没有重大变化。

关于后者:在打开 WebSocket 连接时指定 WebSocket 子协议(protocol),如 this .

关于android - 高速公路异常 WebSockets 协议(protocol)违规,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21143934/

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