TooTallNate / Java-WebSocket

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

Change default PING interval #1358

Closed airas-careem closed 1 year ago

airas-careem commented 1 year ago

Describe what you would like to know or do I want to change the default PING interval which is 1 min

Additional context

Following is my WebSocket client code. I have checked the docs but could not find any option to change the ping interval. The library I am using is

import org.java_websocket.WebSocket; import org.java_websocket.client.WebSocketClient;

` WebSocketClient client = new WebSocketClient(new URI("ws://localhost:8080/BiDiEnvelopeChannel/fabric/bidicommunication")) {

        @Override
        public void onOpen(ServerHandshake handshake) {
            System.out.println("Connection established to the server");
        }

        @Override
        public void onMessage(String message) {
            System.out.println("Received message: " + message);

        }
        @Override
        public void onMessage(ByteBuffer message) {
            try {
                Envelope envelope = Envelope.parseFrom(message.array());
                System.out.println("Received Binary message =====> " + envelope + " ******* ");

            } catch (InvalidProtocolBufferException e) {
                System.out.println("Received Binary message and failed to parse it " + e.getMessage());
                e.printStackTrace();
            }
        }

        @Override
        public void onClose(int code, String reason, boolean remote) {
            System.out.println("Connection closed");
        }

        @Override
        public void onError(Exception ex) {
            System.out.println("error on websocket client: " + ex.getMessage());
        }

         @Override
         public void onWebsocketPong(WebSocket conn, Framedata f) {
             System.out.println("received "+ f.getOpcode());
         }
     };

    client.connect();`
PhilipRoman commented 1 year ago

Do you mean this? https://github.com/TooTallNate/Java-WebSocket/wiki/Lost-connection-detection#change-the-check-interval