koush Websocket握手失败

时间:2016-07-16 19:09:46

标签: java android java-websocket androidasync-koush

我正在通过koush https://github.com/koush/AndroidAsync尝试图书馆。

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

AsyncHttpClient.getDefaultInstance().websocket(uri, null, new AsyncHttpClient.WebSocketConnectCallback() {
            @Override
            public void onCompleted(Exception ex, WebSocket webSocket) {
                if (ex != null) {
                    ex.printStackTrace();
                    return;
                }
                webSocket.send("a string");
                webSocket.send(new byte[10]);
                webSocket.setStringCallback(new WebSocket.StringCallback() {
                    public void onStringAvailable(String s) {
                        System.out.println("I got a string: " + s);
                    }
                });
                webSocket.setDataCallback(new DataCallback() {
                    public void onDataAvailable(DataEmitter emitter, ByteBufferList byteBufferList) {
                        System.out.println("I got some bytes!");
                        // note that this data has been read
                        byteBufferList.recycle();
                    }
                });
            }
        });

}

但是,我收到了WebSocketHandshakeException。有没有办法解决这个问题?enter image description here

0 个答案:

没有答案