powered by Jive Software

Handling lost connections via ReconnectionManager

Hi,

I am using Smack 4.0.3 RC2. I have written a chatBot which is working just fine, logs in, posts messages, receives messages, etc… A requirement was for the program to determine that the connection to the server has been lost, determine when it has recovered and then log back in without user intervention. So, the reconnectionManager looks like exactly what I want, but I can’t get it functioning so I am assuming I am missing something obvious since the rest of the SDK was so easy to use. The problem is the program never detects the connection has been lost so the reconnection is not attempted.

Code Snippet
connection = new XMPPTCPConnection(conf.build());
connection.addConnectionListener(this);
ReconnectionManager manager = ReconnectionManager.getInstanceFor(connection);
manager.addReconnectionListener(this);
manager.enableAutomaticReconnection();
manager.setReconnectionPolicy(ReconnectionManager.ReconnectionPolicy.FIXED_DELAY);
manager.setFixedDelay(XMPPReconnectInterval);
try {
connection.connect();

Once the bot is in the room, I disable the network connection to the Server. The XMPP client detects the connection has been lost, but connectionClosed, connectionClosedOnError, reconnectingIn, nor reconnectionFailed are called.

So what am I missing?

Thanks, Wray