powered by Jive Software

Can't make reconnecting with BOSH work

Hi,

I am using the BOSH files from the BOSH branch.

http://svn.igniterealtime.org/svn/repos/smack/branches/bosh/smack-bosh/src/main/ java/org/jivesoftware/smack/

I have the problem that reconnecting does not work.

  1. The reconnection error listener is never called. Because the following piece of logic in BoshConnection.java does not make any sense at all.

if (connEvent.isError()) {

try {

connEvent.getCause();

}

catch (Exception e) {

notifyConnectionError(e);

}

}

because getCause never throws an exception.

I’ve fixed that.

  1. Then the second problem is, if I reconnect and try to login (due to wasAuthenticated=true), I get no response from server during the SASL Authentication.

Anybody having similar experiences or an idea to my 2nd problem?

Seems that I also found a solution to my second problem:

I had to do the login in a separate thread. In method connectionEvent:

I don’t quite understand it, but obviously something is blocked otherwise.

The branch code also missed the loginAnonymously().

if (wasAuthenticated) {

new Thread() {

public void run() {

try {

if (isAnonymous()) {

// Make the anonymous login

loginAnonymously();

} else {

login(config.getUsername(), config.getPassword(), config.getResource());

}

} catch (XMPPException e) {

for (ConnectionListener listener : getConnectionListeners()) {

listener.reconnectionFailed(e);

}

}

for (ConnectionListener listener : getConnectionListeners()) {

listener.reconnectionSuccessful();

}

}

}.start();

}