powered by Jive Software

How to use ReconnectionManager?

Hello,

Maybe it’s a stupid question, but I cannot find the answer on this forum or in the Smack documentation. I found http://www.igniterealtime.org/builds/smack/docs/latest/javadoc/org/jivesoftware/ smack/ReconnectionManager.html but this don’t tell me how to use the ReconnectionManager fonctionnality.

Thanks for your help!

Nobody for help?

Hi!

ReconnectionManager is actually enabled by default, and as far as I can see is not meant to be used exclicitly (the constructor is private).

If you’d like to verify that it’s actually working, or e.g. do something upon reconnection, you might add a custom ConnectionListener to your XMPPConnection like this:

connection.addConnectionListener(new ConnectionListener() {             @Override
            public void reconnectionSuccessful() {
                logger.info("Successfully reconnected to the XMPP server.");
            }
                        @Override
            public void reconnectionFailed(Exception arg0) {
                logger.info("Failed to reconnect to the XMPP server.");
            }             @Override
            public void reconnectingIn(int seconds) {
                logger.info("Reconnecting in " + seconds + " seconds.");
            }
                        @Override
            public void connectionClosedOnError(Exception arg0) {
                logger.error("Connection to XMPP server was lost.");
            }
                        @Override
            public void connectionClosed() {
                logger.info("XMPP connection was closed.");
            }
        });