【发布时间】:2015-03-13 18:07:52
【问题描述】:
我正在 Ubuntu 上开发。我正在尝试将我的 xmpp 客户端连接到本地 openfire 服务器。
AndroidConnectionConfiguration configuration = new AndroidConnectionConfiguration(
host, Integer.parseInt(port), service);
SASLAuthentication.supportSASLMechanism("PLAIN", 0); // (I tried after removing this line)
configuration.setSASLAuthenticationEnabled(true);
configuration.setDebuggerEnabled(true);
XMPPConnection connection = new XMPPConnection(configuration);
try {
connection.connect();
Log.i("XMPPClient",
"[SettingsDialog] Connected to " + connection.getHost());
} catch (XMPPException ex) {
Log.e("XMPPClient", "[SettingsDialog] Failed to connect to "
+ connection.getHost());
Log.e("XMPPClient", ex.toString());
xmppClient.setConnection(null);
}
try {
connection.login(username, password);
Log.i("XMPPClient", "Logged in as " + connection.getUser());
// Set the status to available
Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);
xmppClient.setConnection(connection);
} catch (XMPPException ex) {
Log.e("XMPPClient", "[SettingsDialog] Failed to log in as "
+ username);
Log.e("XMPPClient", ex.toString());
xmppClient.setConnection(null);
}
现在我可以使用此代码连接 Google 聊天服务器。我也可以在 Ubuntu 上将本地服务器与 Spark 客户端连接。但无法连接到 Android 上的本地服务器。
其中 host 为 10.0.2.2 (Android localhost) 端口 5222 服务 本地主机
Android客户端可以成功连接本地服务器但我无法登录
我收到的错误sasl authentication failed using mechanism digest-md5
我正在搜索过去两天并尝试了很多东西但本地服务器没有成功。
【问题讨论】:
标签: android xmpp openfire asmack