ejabberd服务器中的服务器错误没有响应

时间:2013-04-21 15:15:57

标签: android xmpp ejabberd smack

现在我正在使用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):服务器没有响应。

1 个答案:

答案 0 :(得分: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服务器。我希望这能解决你的问题。

相关问题