1

現在、ejabberd サーバーを使用して Android 用の XMPP-chat を使用しています。

サーバーに接続しようとすると、エラーが表示されます。しかし、openfire サーバーでは正常に動作します。

を使用してsmack libraryいます。

エラーログを以下に示します。

04-21 20:34:16.824: I/XMPPChatDemoActivity(1929): [SettingsDialog] 10.0.2.2 に接続しました 04-21 20:34:21.932: E/XMPPChatDemoActivity(1929): test3@eworks.com としてログインできませんでした04-21 20:34:21.932: E/XMPPChatDemoActivity(1929): サーバーからの応答がありません。

4

1 に答える 1

2

Smack 3.1.0 で gtalk と jabber.org に接続する方法を見つけました。

GTalk のコード:

ConnectionConfiguration cc = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
XMPPConnection connection = new XMPPConnection(cc);
try {
     connection.connect();

     // You have to put this code before you login
     SASLAuthentication.supportSASLMechanism("PLAIN", 0);

     // You have to specify your gmail addres WITH @gmail.com at the end
     connection.login("some.account@gmail.com", "password", "resource");

     // See if you are authenticated
     System.out.println(connection.isAuthenticated());

} catch (XMPPException e1) {
     e1.printStackTrace();
}

jabber.org のコードは次のとおりです。

ConnectionConfiguration cc = new ConnectionConfiguration("jabber.org", 5222, "jabber.org");
XMPPConnection connection = new XMPPConnection(cc);
try {
     connection.connect();

     // You have to put this code before you login
     SASLAuthentication.supportSASLMechanism("PLAIN", 0);

     // You have to specify your Jabber ID addres WITHOUT @jabber.org at the end
     connection.login("your.jabber", "password", "resource");

     // See if you are authenticated
     System.out.println(connection.isAuthenticated());

} catch (XMPPException e1) {
     e1.printStackTrace();
}

このコードを使用して、ローカルの ejabberd および openfire サーバーに接続できるようになりました。これで問題が解決することを願っています。

于 2013-04-22T05:41:54.753 に答える