Package org.glassfish.tyrus.client
Class ClientManager.ReconnectHandler
java.lang.Object
org.glassfish.tyrus.client.ClientManager.ReconnectHandler
- Enclosing class:
ClientManager
Reconnect handler.
When implementing, be sure that you do have enough logic behind cancelling reconnect feature - even Session.close() call will be treated just like any other disconnect resulting in reconnect.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlonggetDelay()Get reconnect delay.booleanonConnectFailure(Exception exception) Called when there is a connection failure.booleanonDisconnect(CloseReason closeReason) Called afterOnCloseannotated method (orEndpoint.onClose(jakarta.websocket.Session, jakarta.websocket.CloseReason)is invoked.
-
Constructor Details
-
ReconnectHandler
public ReconnectHandler()
-
-
Method Details
-
onDisconnect
Called afterOnCloseannotated method (orEndpoint.onClose(jakarta.websocket.Session, jakarta.websocket.CloseReason)is invoked.- Parameters:
closeReason- close reason passed to onClose method.- Returns:
- When
trueis returned, client container will reconnect.
-
onConnectFailure
Called when there is a connection failure.Type of the failure is indicated by
Exceptionparameter. Be cautious when implementing this method, you might easily cause DDoS like behaviour.- Parameters:
exception- Exception thrown during connection phase.- Returns:
- When
trueis returned, client container will reconnect.
-
getDelay
public long getDelay()Get reconnect delay.Called after
onDisconnect(CloseReason)oronConnectFailure(Exception)whentrueis returned. When positive value is returned, next connection attempt will be made after that number of seconds.Default implementation returns 5L.
- Returns:
- reconnect delay in seconds.
-