How to make Sockets secured in Java backend?

108 Views Asked by At

I'm new to sockets, I'm trying to make connection of secured sockets. It is working fine with Http But I'm failing continuously with Https, How can I make a secured socket connection in java?

try{
    requestSocket = IO.socket(REQUEST_SOC_URL);
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        try {
            requestSocket.on(Socket.EVENT_DISCONNECT, new Listener() {
                @Override
                public void call(Object... args) {
                }
            }).on(Socket.EVENT_CONNECT, new Listener() {
                @Override
                public void call(Object... arg0) {
                    try {
                        // emitting data here

                    } catch (JsonProcessingException e) {
                        e.printStackTrace();
                    }
                }
            }).on(Socket.EVENT_CONNECT_ERROR, new Listener() {
                @Override
                public void call(Object... arg0) {
                    System.out.println("error");
                    System.out.println(arg0[0]);
                }
            });
            requestSocket.connect();
        } catch (Exception e) {
        }
0

There are 0 best solutions below