[英]Why can't I connect to the openfire server?
I'm having a little bit of trouble trying to connect to Openfire (which I've installed on my computer) while using Smack. 使用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");
When I try debugging or running, there's an error of some sort in the connect()
line. 当我尝试调试或运行时,
connect()
行中出现某种错误。
XMPPError connecting to localhost:5222.: remote-server-error(502) XMPPError connecting to localhost:5222. XMPPError连接到本地主机:5222 。: remote-server-error(502)XMPPError连接到本地主机:5222。 -- caused by: java.net.SocketException: Permission denied.
-由以下原因引起:java.net.SocketException:权限被拒绝。
I've tried switching the host name to "localhost", and it didn't work either. 我尝试将主机名切换为“ localhost”,但也没有用。
I have no experience in this XMPP business so I guess it's a common newbie problem or something of the sort... 我没有从事XMPP业务的经验,所以我想这是一个常见的新手问题或类似问题。
What might be the problem? 可能是什么问题? How can I fix this so the connection will be successful?
如何解决此问题,以便连接成功?
I just created a new project in which I need XMPP, and ran into the same problem. 我刚刚创建了一个需要XMPP的新项目,并且遇到了同样的问题。 However, I realized that it was simply because I had forgotten to add the internet permission in my manifest:
但是,我意识到这仅仅是因为我忘记在清单中添加互联网许可:
<uses-permission android:name="android.permission.INTERNET"/>
Make sure that you haven't done the same mistake. 确保您没有犯同样的错误。
I have Same problem .... but i resolved this issue at my end using following steps ::: 我有同样的问题....,但是我最终使用以下步骤解决了这个问题:::
1) Firstly checked Internet permission 1)首先检查互联网权限
<uses-permission android:name="android.permission.INTERNET"/>
2) Then open the openfire.xml file from C:\\Openfire\\conf (Installation directory) and edit the file 2)然后从C:\\ Openfire \\ conf(安装目录)打开openfire.xml文件并编辑该文件
<network>
<interface>Your IP Address(192.168.0.1)</interface>
</network>
and save the file and start the openfire server. 并保存文件并启动openfire服务器。 I think it will be helpful for you....
我认为这将对您有所帮助。
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 使用您的服务器openfire的IP地址
Use host as localhost if you are using a device. 如果使用设备,则将host用作localhost。 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)
如果使用仿真器,请在配置步骤(给定代码的第1行)中使用IP地址(192.168.1.2或其他值)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.