我正在尝试在 asmack 库的帮助下使用 android 中的 BOSH Manager 与 ejabber 连接。
但我收到以下错误。
Caused by: java.lang.IllegalStateException: Not logged in to server.
at org.jivesoftware.smack.Roster.reload(Roster.java:197)
at org.jivesoftware.smack.BOSHConnection.login(BOSHConnection.java:351)
at org.jivesoftware.smack.Connection.login(Connection.java:353)
at com.bcl.BoradCastLocationActivity$StartXMPPConnection.doInBackground(BoradCastLocationActivity.java:75)
at com.bcl.BoradCastLocationActivity$StartXMPPConnection.doInBackground(BoradCastLocationActivity.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:185)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
... 4 more
这是我的代码
SASLAuthentication.registerSASLMechanism("DIGEST-MD5",SASLDigestMD5Mechanism.class);
SASLAuthentication.supportSASLMechanism("DIGEST-MD5", 1);
System.setProperty("smack.debugEnabled", "true");
XMPPConnection.DEBUG_ENABLED = true;
SmackConfiguration.setPacketReplyTimeout(6000);
BOSHConfiguration bconfig = new
BOSHConfiguration(false, "example.com", 5280, "/xmpp-http-bind/", "example.com");
bconfig.setSASLAuthenticationEnabled(true);
BOSHConnection xmpp = new BOSHConnection(bconfig);
xmpp.connect();
xmpp.login("username","password"); // HERE I AM GETTING AN ERROR