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

标签 android websocket jetty autobahn

在我的 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/

相关文章:

android - 无法使用 Android Studio 构建 GStreamer 教程

java.lang.SecurityException : BLUETOOTH permission crash.(仅限三星设备)

java - Json Jackson 不反序列化内部对象(属性上为 null)

python - 检查 websocket 客户端的 URL - python

java - 如何在 Jetty 上使用 JASPI/JASPIC?

android - 该项目可能正在使用不包含方法 'compileSdkVersion()' 的 Gradle 版本

django - 将请求从一个 uwsgi 分派(dispatch)到另一个运行 Django Channels 的 uwsgi 实例

amazon-web-services - 使用 CloudFormation 时,AWS Lambda 函数缺少由 websocket 网关触发

java - 如何将参数传递给jetty服务

jakarta-ee - Jetty hello world 中的 ClassNotFoundException : javax. servlet.AsyncContext