1

私のAndroidアプリケーションでは、autobahnライブラリを使用してwebsocketを使用したいと考えています.

サーバーはdraft-17を使用していると思います。このプロトコルを使用するようにクライアントを設定する方法を教えてもらえますか?

私はこのコードを持っています:

      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
4

1 に答える 1

1

WebSocket プロトコル バージョンまたは WebSocket サブプロトコルを参照していますか?

前者に関して: AutobahnAndroid は RFC6455 (最後で最後の WebSocket プロトコル バージョン) を実装しています。古いバージョンにダウングレードする方法はありませんが、基本的に、Hybi-10+ から RFC6455 への大幅な変更はありません。

後者に関して: WebSocket サブプロトコルは、このように WebSocket 接続を開くときに指定されます。

于 2014-01-15T17:53:11.013 に答える