为什么我无法连接到 openfire 服务器?
我在使用 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 连接到 localhost:5222.: 远程服务器错误(502) XMPPError 连接到 localhost:5222。 -- 导致:java.net.SocketException:权限被拒绝。
我尝试将主机名切换为“localhost”,但也不起作用。
我在 XMPP 业务方面没有经验,所以我猜这是一个常见的新手问题或类似的问题...
可能是什么问题?我该如何解决这个问题以便连接成功?
I'm having a little bit of trouble trying to connect to Openfire (which I've installed on my computer) while using Smack.
ConnectionConfiguration config = new ConnectionConfiguration("shin-pc" ,5222);
config.setCompressionEnabled(true);
config.setSASLAuthenticationEnabled(true);
XMPPConnection connection = new XMPPConnection(config);
connection.connect();
connection.login("test", "test");
When I try debugging or running, there's an error of some sort in the connect()
line.
XMPPError connecting to localhost:5222.: remote-server-error(502) XMPPError connecting to localhost:5222. -- caused by: java.net.SocketException: Permission denied.
I've tried switching the host name to "localhost", and it didn't work either.
I have no experience in this XMPP business so I guess it's a common newbie problem or something of the sort...
What might be the problem? How can I fix this so the connection will be successful?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我刚刚创建了一个需要 XMPP 的新项目,并遇到了同样的问题。然而,我意识到这只是因为我忘记在清单中添加互联网权限:
确保您没有犯同样的错误。
I just created a new project in which I need XMPP, and ran into the same problem. However, I realized that it was simply because I had forgotten to add the internet permission in my manifest:
Make sure that you haven't done the same mistake.
我有同样的问题....但我最终使用以下步骤解决了这个问题:::
1) 首先检查互联网权限
2) 然后从 C:\Openfire\conf (安装目录)打开 openfire.xml 文件并编辑文件
并保存文件并启动 openfire 服务器。
我想这会对你有帮助......
I have Same problem .... but i resolved this issue at my end using following steps :::
1) Firstly checked Internet permission
2) Then open the openfire.xml file from C:\Openfire\conf (Installation directory) and edit the file
and save the file and start the openfire server.
I think it will be helpful for you....
我遇到了同样的问题,我按照以下步骤解决了它:
首先禁用您的防火墙
使用您的服务器openfire的IP地址
i had the same problem, i followed these steps to solve it:
disable your firewall first
use your the IP address of your server openfire
如果您使用的是设备,请使用主机作为本地主机。
如果您使用模拟器,请在配置步骤(给定代码的第 1 行)中使用 IP 地址(192.168.1.2 或其他)
Use host as localhost if you are using a device.
If you are using an emulator, use ip address (192.168.1.2 or whatever) in the configuration step (line 1 of the given code)