public void onConnectionClosed ( ) { logger . debug ( "[onConnectionClosed] '{}', isConnected = {}" , uri , isConnected ( ) ) ; webSocketConnectionManager . stop ( ) ; timer = new Timer ( ) ; timer . schedule ( new TimerTask ( ) { @ Override public void run ( ) { logger . debug ( "[onConnectionClosed:run]" ) ; synchronized ( webSocketHandler . getNotifyConnectionObject ( ) ) { webSocketConnectionManager . start ( ) ; try { webSocketHandler . getNotifyConnectionObject ( ) . wait ( TimeUnit . SECONDS . toMillis ( WEBSOCKET_RECONNECT_TIMEOUT ) ) ; } catch ( InterruptedException e ) { logger . debug ( "[onConnectionClose]" , e ) ; } if ( isConnected ( ) ) { logger . debug ( "[onConnectionClosed:run] connected" ) ; clusterListener . onServerReconnected ( getServerId ( ) , uri ) ; this . cancel ( ) ; } else { logger . debug ( "[onConnectionClosed:run] NOT connected" ) ; webSocketConnectionManager . stop ( ) ; } } } } , TimeUnit . SECONDS . toMillis ( WEBSOCKET_TIMEOUT ) , TimeUnit . SECONDS . toMillis ( WEBSOCKET_RECONNECT_TIMEOUT ) ) ; }
Is being called when the websocket connection was closed and tries to reconnect .