carlosCharz / fcmxmppserverv2

XMPP Connection Server for FCM using the latest version of the Smack library (4.3.4) + Connection Draining Implementation
47 stars 33 forks source link

Change ReconnectManager Policy #11

Closed isadounikau closed 7 years ago

carlosCharz commented 7 years ago

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.

carlosCharz commented 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 { /**

carlosCharz commented 7 years ago

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!