gusavila92 / java-android-websocket-client

Java/Android WebSocket Client
Apache License 2.0
148 stars 40 forks source link

i get headers instead of my sending data #14

Open Ebrahimjz opened 5 years ago

Ebrahimjz commented 5 years ago

hi I am trying to send data with this library and when i see results in other side it sends just headers i cant find data ` private static final int PORT_NUMBER = 3030; private static final String HOST_ADDRESS = "192.168.1.102"; public static final String WEB_SOCKET_URL = "ws://" + HOST_ADDRESS + ":" + PORT_NUMBER + "/";

@Override protected Void doInBackground(Void... voids) { URI uri = null; try { uri = new URI(wsConfig.WEB_SOCKET_URL); } catch (URISyntaxException e) { e.printStackTrace();

    }

    webSocketClient = new WebSocketClient(uri) {
        @Override
        public void onOpen() {
            Log.i(TAG, "onOpen: "+"opened!!!");
                webSocketClient.send(Data);
        }

        @Override
        public void onTextReceived(String message) {
            System.out.println("onTextReceived");
        }

        @Override
        public void onBinaryReceived(byte[] data) {
            System.out.println("onBinaryReceived");
        }

        @Override
        public void onPingReceived(byte[] data) {
            System.out.println("onPingReceived");
        }

        @Override
        public void onPongReceived(byte[] data) {
            System.out.println("onPongReceived");
        }

        @Override
        public void onException(Exception e) {
            System.out.println("errrrroorrr"+e.getMessage());
        }

        @Override
        public void onCloseReceived() {
            System.out.println("onCloseReceived");
        }
    };

    webSocketClient.setConnectTimeout(10000);
    webSocketClient.setReadTimeout(60000);
    webSocketClient.enableAutomaticReconnection(5000);
    webSocketClient.connect();

`

result i get is like this on ws: GET /HTTP /1.1 Host: my sender ip upgrade:websocket connection :Upgrade Sec-webSocket:.....

and for wss i get some thing that cannot read or not like any language i thing it is encrypted

i hope you can help me i spend hole 2 week on this

gusavila92 commented 2 years ago

does this always happen? How big is the data that you're trying to send? what server library are you using? did you try using a different server?