为什么我无法连接到openfire服务器?
在使用Smack时尝试连接到Openfire(我已安装在计算机上)时遇到了一些麻烦。
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");
当我尝试调试或运行时,中出现某种错误connect()
line。
When I try debugging or running, there's an error of some sort in the connect()
line.
连接到localhost的XMPPError:5222:remote-server-error(502)连接到localhost的XMPPError :5222。 - 由:java.net.SocketException:权限被拒绝。
我尝试将主机名切换为localhost,它没有'或者工作。
I've tried switching the host name to "localhost", and it didn't work either.
我没有这个XMPP业务的经验所以我想这是一个常见的新手问题或类似的东西......
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?
我刚刚创建了一个我需要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:
<uses-permission android:name="android.permission.INTERNET"/>
确保你没有犯同样的错误。
Make sure that you haven't done the same mistake.