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

Bar*_*Bar 1 java openfire 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");
Run Code Online (Sandbox Code Playgroud)

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

连接到localhost的XMPPError:5222:remote-server-error(502)连接到localhost的XMPPError:5222. - 由:java.net.SocketException引起:权限被拒绝.

我已经尝试将主机名切换为"localhost",但它也没有用.

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

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

Jav*_*ave 5

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

<uses-permission android:name="android.permission.INTERNET"/>
Run Code Online (Sandbox Code Playgroud)

确保你没有犯同样的错误.