TooTallNate / Java-WebSocket

A barebones WebSocket client and server implementation written in 100% Java.
http://tootallnate.github.io/Java-WebSocket
MIT License
10.54k stars 2.58k forks source link

Invalid status code received: 520 #590

Closed trashCoder555 closed 7 years ago

trashCoder555 commented 7 years ago

Hello everyone. Im using android studio and trying to connect socket. After mWebSocketClient.connectBlocking(); i got "Invalid status code received: 520"

using ver. 1.3.5 (Tested with many others - same, not working)

My code: private void connectWebSocket() { URI uri; try { uri = new URI("wss://socket.etherdelta.com"); // uri = new URI("ws://echo.websocket.org"); } catch (URISyntaxException e) { e.printStackTrace(); return; }

    mWebSocketClient = new WebSocketClient(uri, new Draft_6455()) {
        @Override
        public void onOpen(ServerHandshake serverHandshake) {
            Log.i("Websocket", "Opened");
            mWebSocketClient.send("getMarket");
        }

        @Override
        public void onMessage(String s) {
            final String message = s;
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    TextView textView = (TextView) findViewById(R.id.messages);
                    textView.setText(textView.getText() + "\n" + message);
                }
            });
        }

        @Override
        public void onClose(int i, String s, boolean b) {
            Log.i("Websocket", "Closed " + s);
        }

        @Override
        public void onError(Exception e) {
            Log.i("Websocket", "Error " + e.getMessage());
        }
    };

    try {
        mWebSocketClient.setSocket(HttpsURLConnection.getDefaultSSLSocketFactory().createSocket());
        mWebSocketClient.connectBlocking();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
marci4 commented 7 years ago

Please use the template provided for any bug report. It is there for a reason to help me understand the problems.

trashCoder555 commented 7 years ago

All I'm doing is trying to connect wss. And first callback is called is onClose.

{GET / HTTP/1.1 Connection: Upgrade Host: socket.etherdelta.com:443 Sec-WebSocket-Key: WePxYcl8ybLXIBKYzBtd/A== Sec-WebSocket-Version: 13 Upgrade: websocket } Disconnected, reason = Invalid status code received: 520, exit code = 1002

trashCoder555 commented 7 years ago

If i'm trying to connect "ws://socket.etherdelta.com" instead of "wss://socket.etherdelta.com"

I got this:

javax.net.ssl.SSLHandshakeException: Handshake failed Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xdfd0f200: Failure in SSL library, usually a protocol error error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:790 0xeb4580b4:0x00000000)

trashCoder555 commented 7 years ago

api was broken... with another link it works fine