gpt4 book ai didi

java - 为什么我无法连接到 openfire 服务器?

转载 作者:行者123 更新时间:2023-11-29 10:06:24 27 4
gpt4 key购买 nike

我在使用 Smack 时尝试连接到 Openfire(我已经安装在我的计算机上)时遇到了一些麻烦。

    ConnectionConfiguration config = new ConnectionConfiguration("shin-pc" ,5222);
config.setCompressionEnabled(true);
config.setSASLAuthenticationEnabled(true);
XMPPConnection connection = new XMPPConnection(config);
connection.connect();
connection.login("test", "test");

当我尝试调试或运行时,connect() 行中出现某种错误。

XMPPError connecting to localhost:5222.: remote-server-error(502) XMPPError 连接到 localhost:5222。 -- 原因:java.net.SocketException:权限被拒绝。

我试过将主机名切换为“localhost”,但也没有用。

我没有这方面的 XMPP 业务经验,所以我猜这是一个常见的新手问题或类似的问题......

可能是什么问题?我该如何解决这个问题才能成功连接?

最佳答案

我刚刚创建了一个需要 XMPP 的新项目,但遇到了同样的问题。但是,我意识到这仅仅是因为我忘记在我的 list 中添加互联网权限:

<uses-permission android:name="android.permission.INTERNET"/>

确保您没有犯同样的错误。

关于java - 为什么我无法连接到 openfire 服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6804236/

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