1

我一直在尝试使用 aSmack jar 通过 XMPP 协议连接到 Facebook 聊天。但我收到一条错误消息:Error: SASL authentication failed using mechanism DIGEST-MD5

这是例外:

07-05 15:00:48.833: E/Smack(17661): Error: SASL authentication failed using mechanism DIGEST-MD5
07-05 15:00:48.833: W/System.err(17661): SASL authentication failed using mechanism DIGEST-MD5: 
07-05 15:00:48.843: W/System.err(17661):    at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:341)
07-05 15:00:48.843: W/System.err(17661):    at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:204)
07-05 15:00:48.843: W/System.err(17661):    at org.jivesoftware.smack.Connection.login(Connection.java:357)
07-05 15:00:48.843: W/System.err(17661):    at com.example.xmpp.MessageTask.doInBackground(MessageTask.java:52)
07-05 15:00:48.843: W/System.err(17661):    at com.example.xmpp.MessageTask.doInBackground(MessageTask.java:1)
07-05 15:00:48.843: W/System.err(17661):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-05 15:00:48.843: W/System.err(17661):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-05 15:00:48.843: W/System.err(17661):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-05 15:00:48.843: W/System.err(17661):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
07-05 15:00:48.843: W/System.err(17661):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
07-05 15:00:48.853: W/System.err(17661):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
07-05 15:00:48.853: W/System.err(17661):    at java.lang.Thread.run(Thread.java:856)

我尝试登录的用户名和密码是我通常用来登录 Facebook 的凭据。

这是代码:

ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com", 5222);
        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);
        }

        XMPPConnection connection =  new XMPPConnection(config);
        try {
            connection.connect();
            connection.login(user, pwd);

        } catch (Exception e) {
            // TODO Auto-generated catch block
            Log.e("Smack", "Error: " + e.getMessage());
            e.printStackTrace();
        }
4

0 回答 0