我正在开发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) port 5222 service localhost
Android客户端可以成功连接本地服务器,但我无法登录
我得到的错误 sasl authentication failed using mechanism digest-md5
我正在搜索过去两天,尝试了很多东西,但本地服务器没有成功 .
1 回答
试试这个连接:
如果它返回true则登陆xmpp如下: