Android ejabberd服务器中的服务器错误没有响应
现在我正在使用ejabberd服务器与Android的XMPP聊天 当我试图连接到服务器时,它显示一个错误。但它在openfire服务器中运行良好 我正在使用Android ejabberd服务器中的服务器错误没有响应,android,xmpp,ejabberd,smack,Android,Xmpp,Ejabberd,Smack,现在我正在使用ejabberd服务器与Android的XMPP聊天 当我试图连接到服务器时,它显示一个错误。但它在openfire服务器中运行良好 我正在使用smack库 错误日志如下所示: 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
smack库
错误日志如下所示:
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):服务器没有响应
我找到了使用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服务器。我希望这能解决你的问题