gpt4 book ai didi

android - 无法使用 XMPP android 客户端连接到 XMPP 服务器 (Openfire)

转载 作者:行者123 更新时间:2023-11-29 21:36:05 25 4
gpt4 key购买 nike

我在远程服务器上安装了 openfire。我可以使用 Spark XMPP 客户端连接到它。但是当我使用我的 Android XMPP 客户端时出现连接错误。这是 Android 客户端应用程序的连接代码部分:

// Create a connection
String serverIp = "14.63.XXX.XXX";
ConnectionConfiguration connConfig =
new ConnectionConfiguration(serverIp, 5222);
connConfig.setSASLAuthenticationEnabled(true);
XMPPConnection connection = new XMPPConnection(connConfig);


try {
connection.connect();
Log.i("XMPPClient", "Connected to " + connection.getHost());
} catch (XMPPException ex) {
Log.e("XMPPClient", "Failed to connect to " + connection.getHost());
Log.e("XMPPClient", ex.toString());
xmppClient.setConnection(null);
}
try {
connection.login(username, password);
.......

我在 connection.connect() 时出错;被执行。我检查了服务器上的端口并打开了它。我也试过5223端口。我也检查了 XMPP 客户端的权限。我用谷歌搜索并找不到解决此问题的解决方案。有人可以建议我该怎么做吗?

最佳答案

找到临时解决方案:)..我将代码的连接部分放在 AsyncTask ( http://developer.android.com/reference/android/os/AsyncTask.html ) 中。现在它工作正常,但我也做了其他事情,我使用了网络上另一个已经运行的项目的 smack API 库。所以我仍在搜索适用于我的项目的 smack api。我看过http://asmack.org ..但对我没有用!

关于android - 无法使用 XMPP android 客户端连接到 XMPP 服务器 (Openfire),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18418226/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com