You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are there any possible when getDelay will not be invoked and we should use Thread.sleep inside reconnection handler?
ClientManager client = ClientManager.createClient();
ClientManager.ReconnectHandler reconnectHandler = new ClientManager.ReconnectHandler() {
private int counter = 0;
@Override
public boolean onDisconnect(CloseReason closeReason) {
counter++;
if (counter <= 3) {
System.out.println("### Reconnecting... (reconnect count: " + counter + ")");
return true;
} else {
return false;
}
}
@Override
public boolean onConnectFailure(Exception exception) {
counter++;
if (counter <= 3) {
System.out.println("### Reconnecting... (reconnect count: " + counter + ") " + exception.getMessage());
// Thread.sleep(...) or something other "sleep-like" expression can be put here - you might want
// to do it here to avoid potential DDoS when you don't limit number of reconnects.
return true;
} else {
return false;
}
}
@Override
public long getDelay() {
return 1;
}
};
client.getProperties().put(ClientProperties.RECONNECT_HANDLER, reconnectHandler);
client.connectToServer(...)
The text was updated successfully, but these errors were encountered:
zagorulkinde
changed the title
Question regarding reconnection handler usage from docs.
Question regarding ReconnectionHandler usage from docs.
Sep 21, 2020
Are there any possible when getDelay will not be invoked and we should use Thread.sleep inside reconnection handler?
The text was updated successfully, but these errors were encountered: