Can't login right after a createAccount without using a different connection?

I noticed if my jabber server (jabberd2) has account registration enabled, then in Smack if I try to create a new account and then immediately using that account to login, the login fails with an exception complaining Smack fails to receive the response to it final resource bind request (the SASL plain text authentication does succeed and at server side the bind also happens, it’s just somehow Smack didn’t get the bind success response from server). As a workaround, I tried to disconnect the XMPP connection after createAccount, then reconnect before the login, and that worked. I wonder why this happens?


XMPPConnection xcon = new XMPPConnection(“”);


String acct = “test_” + new Random().nextInt(1000000);

String passwd = “test_pwd”;

xcon.getAccountManager().createAccount(acct, passwd);

// following 3 lines are a must otherwise login will fail


xcon = new XMPPConnection(“”);


xcon.login(acct, passwd);

Here is the exact exception:

Exception in thread “main” No response from the server.:

at org.jivesoftware.smack.SASLAuthentication.bindResourceAndEstablishSession(

at org.jivesoftware.smack.SASLAuthentication.authenticate(

at org.jivesoftware.smack.XMPPConnection.login(

at org.jivesoftware.smack.XMPPConnection.login(

at org.jivesoftware.smack.XMPPConnection.login(