我在聊天应用中使用Smack时看到了这个错误。
当我尝试登录我的应用时,每次都无法登录。
这是我的logCat。
Xmpp==>SASL authentication failed using mechanism DIGEST-MD5: 02-15 10:55:00.385: E/Oxygen(4187): at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:341)
02-15 10:55:00.385: E/Oxygen(4187): at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:242)
02-15 10:55:00.385: E/Oxygen(4187): at org.jivesoftware.smack.Connection.login(Connection.java:371)
02-15 10:55:00.385: E/Oxygen(4187): at free_call.chat.oxygen.util.XmppTool.login(XmppTool.java:434)
02-15 10:55:00.385: E/Oxygen(4187): at free_call.chat.oxygen.PresenceService.userLogin(PresenceService.java:818)
02-15 10:55:00.385: E/Oxygen(4187): at free_call.chat.oxygen.PresenceService.xxampServerLogin(PresenceService.java:728)
02-15 10:55:00.385: E/Oxygen(4187): at free_call.chat.oxygen.PresenceService$xampRegistation.doInBackground(PresenceService.java:870)
02-15 10:55:00.385: E/Oxygen(4187): at free_call.chat.oxygen.PresenceService$xampRegistation.doInBackground(PresenceService.java:1)
02-15 10:55:00.385: E/Oxygen(4187): at android.os.AsyncTask$2.call(AsyncTask.java:292)
02-15 10:55:00.385: E/Oxygen(4187): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
02-15 10:55:00.385: E/Oxygen(4187): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
02-15 10:55:00.385: E/Oxygen(4187): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
02-15 10:55:00.385: E/Oxygen(4187): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
02-15 10:55:00.385: E/Oxygen(4187): at java.lang.Thread.run(Thread.java:818)
02-15 10:55:00.385: E/xxamp status1(4187): xxamp server not connected
答案 0 :(得分:0)
我使用了以下代码,它对我有用..
ConnectionConfiguration config = new ConnectionConfiguration("your_server", port_no);
config.setSASLAuthenticationEnabled(true);
config.setCompressionEnabled(true);
config.setSecurityMode(SecurityMode.enabled);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
config.setTruststoreType("AndroidCAStore");
config.setTruststorePassword(null);
config.setTruststorePath(null);
} else {
config.setTruststoreType("BKS");
String path = System.getProperty("javax.net.ssl.trustStore");
if (path == null)
path = System.getProperty("java.home") + File.separator + "etc"
+ File.separator + "security" + File.separator
+ "cacerts.bks";
config.setTruststorePath(path);
}