Ad

Sending Data To A Special Device

- 1 answer

I am trying to send some data through socket via 192.168.... some IP address and port to device that is listening to that IP and port and my problem is this that i send data but device get another thing that i cant understand what is it.

I will send my code and images and i almost forget to use library for using socket to send data from github => tech.gusavila92:java-android-websocket-client:1.2.0

socket result image first image is for http request and second is for https same for ws and wss

I found that show headers as result but i don't want these i want my data and i don't see any 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 = "https://" + 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();

enter image description here

Ad

Answer

ok at last i found my question solution on my self and that is this i used another class to connect to socket so i don't know what happened but it just send some data from socket connection information i take codes in main class and its done and works correctly i mean i don't have to use another class to connect via socket

Ad
source: stackoverflow.com
Ad