XMPPサーバーに接続している間、SASL認証が失敗します
-
03-10-2019 - |
質問
XMPPサーバーを介してSmack APIを使用してGmailに接続しようとしています。しかし、
エラー:SASL認証は、メカニズムプレーンを使用して失敗しました
コードを垣間見ることができます。ネットだけから手に入れました
ConnectionConfiguration connConfig = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
connection = new XMPPConnection(connConfig);
connection.connect();
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
スマックデバッグウィンドウをチェックしました。 XMLには次のように書かれています。
<invalid-authzid />
私はすでにGmailでアカウントを持っていて、私のGTALKも実行されています。
解決
接続する前に認証を設定する必要があります
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
前に現れる必要があります connection.connect()
.
私を見てください ブログ.
他のヒント
ConnectionConfiguration cc = new ConnectionConfiguration(
"vietnam.agilemobile.com", 5222, vietnam.agilemobile.com");
XMPPConnection connection = new XMPPConnection(cc);
try {
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
connection.connect();
Log.e("LOGIN", "" + 111);
// You have to put this code before you login
Log.e("LOGIN", "" + 222);
// You have to specify your gmail addres WITH @gmail.com at the end
connection.login("nemodo", "123456", "resource");
Log.e("LOGIN", "" + 333);
// See if you are authenticated
System.out.println(connection.isAuthenticated());
} catch (XMPPException e1) {
e1.printStackTrace();
}
私もこの間違いを受けますが、私は働くことができません。
所属していません StackOverflow