无法将Android客户端与本地XMPP服务器连接

Ame*_*dke 3 android xmpp client-server smack tigase

这是关于发布在这里

我能够将我的PC连接到本地的本地tigase服务器设置(我正在使用Smack API).现在,当我想通过Wi-Fi将Android Phone连接到该服务器时,我遇到了问题.我能够通过使用客户端Beem连接到本地服务器android.My XMPP服务器的域名是我的PC名称"mwbn43-1",IP地址是"192.168.0.221"(我能够ping这个服务器从Android终端模拟器).在Beem设置中有一个高级选项,我可以指定我要连接的服务器(我已经将其作为IP地址).如果我没有设置此选项,我无法conect.Now这里是的片段代码我用于我的Android客户端.

    XMPPConnection.DEBUG_ENABLED = true;
    ConnectionConfiguration config = new ConnectionConfiguration("mwbn43-1",5222);

    //ConnectionConfiguration config = new ConnectionConfiguration("192.168.0.221",5222);             
    config.setSASLAuthenticationEnabled(false);
    config.setCompressionEnabled(false);

    XMPPConnection xmpp = new XMPPConnection(config);

    try {

            xmpp.connect(); 

            xmpp.login("admin@mwbn43-1", "tigase");
            String host = xmpp.getHost();
            String id = xmpp.getConnectionID();
            int port = xmpp.getPort();
            boolean i = false;
            i = xmpp.isConnected();
            if(i)
            {answer = "Connected to " + host + " via port " + port + " with ID " + id;
            answerfield.setText(answer);}

          }//end try 
    catch (XMPPException e) {  
     answerfield.setText("Failed to connect");
     Log.v(TAG, "Failed to connect to " + xmpp.getHost());
            e.printStackTrace();
Run Code Online (Sandbox Code Playgroud)

我也可以借助此代码连接谷歌谈话服务器.虽然与本地服务器建立连接,我尝试提供IP地址以及主机名连接.当我给IP地址(192.168.0.221)我得到'没有回复从服务器错误'与流:错误(主机 - 未知)和当我给主机名(mwbn43-1)我得到'远程服务器超时(504)'主机未解决.

我查看了Beem的代码,看看它是如何与服务器连接但找不到太多.我也给了Internet的用户权限.任何人都可以告诉我应该添加什么行代码来与本地服务器通信.

msc*_*ker 6

尝试3参数ConnectionConfiguration构造函数.它让你说明主机,端口和域.主机和域不必是相同的值.在你的情况下,我想:

ConnectionConfiguration config = 
  new ConnectionConfiguration("192.168.0.221",5222,"mwbn43-1");
Run Code Online (Sandbox Code Playgroud)