powered by Jive Software

Unable to add ConnectionListener before connecting?

In the method org.jivesoftware.smack.Connection.addConnectionListener() it has a guard to not accept a ConnectionListener unless the underlying connection is already connected. I see no reason to impose such a restriction that ConnectionListeners should only be added after the connection is made. In fact it actually causes us an issue where the connection fails before returning from the XMPPConnect.connect() call.

This has come about because we have implmented the see-other-host extension which requires to know that connection fails due to receiving the See-Other-Host message.

Our question is can the !connected() call be safely removed from the addConnectionListener() method?

Without analyzing the reason I can say that this behavior was introduced with 6050. See here: http://fisheye.igniterealtime.org/changelog/smack?cs=6050

Usually there is a reason for that.