Closed isadounikau closed 7 years ago
I was checking the source code and they are using the RANDOM one. Look:
private static ReconnectionPolicy defaultReconnectionPolicy = ReconnectionPolicy.RANDOM_INCREASING_DELAY;
public enum ReconnectionPolicy { /**
overall number of attempts. */ RANDOM_INCREASING_DELAY,
/**
Let leave the code as it is to let the guys know that in case they need to perform other action they can do it. This is my real implementation of the reconnection in my real project (I customized this solution):
public synchronized void reconnection() { BackOffStrategy backoff = new BackOffStrategy(5, 1000); while (backoff.shouldRetry()) { try { initialize(); backoff.doNotRetry(); } catch (XMPPException | SmackException | IOException | InterruptedException e) { logger.info("The notifier server could not reconnect after the connection draining message"); backoff.errorOccured(); } } }
private void handleConnectionDrainingFailure() { logger.info("FCM Connection is draining! Initiating reconnection ..."); ccsConnection.reconnection(); }
I thank you the thing to put synchronized to the method! I am gonna commit that to this project! Thanks!
Hi. Take into account that this reconnection is from the smack side and for FCM google will send you a connection draining and we need to reconnect manually! This improvement is for our side but not for FCM. We still need this reconnection.