2015-09-19 226 views
0

我打算从我的android应用程序连接到ejabberd本地主机ejabbered服务器不显示ejabberd web管理员上的在线用户。无法连接到ejabberd本地主机

AbstractXMPPConnection conn1; 
    conn1 = new XMPPTCPConnection("[email protected]", "password", "192.168.1.23"); 

     conn1.connect(); 
     if(conn1.isConnected()) 
     { 
      Toast.makeText(this,"conn 1 successfull",Toast.LENGTH_LONG).show(); 
    } 



    // Create a connection to the jabber.org server on a specific port. 
    XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder() 
      .setUsernameAndPassword("[email protected]", "password") 
      .setServiceName("jabber.org") 
      .setHost("192.1**.1.2*")//My Ip address 
      .setPort(5222) 
      .setDebuggerEnabled(true) 
      .build(); 

    AbstractXMPPConnection conn2 = new XMPPTCPConnection(config); 

     conn2.connect(); 
     if(conn2.isConnected()) 
     { 
      Toast.makeText(this,"conn2 successfull",Toast.LENGTH_LONG).show(); 
     } 

回答

0

你的代码看起来不正确:

  • 用户名应该是不XMPP域(只是身份识别码)的用户名。
  • ServiceName设置为“jabber.org”,这意味着您将尝试连接到该服务器,而不是您的本地服务器。
+0

如果192.168.1.24:5280/admin是域,那么我应该在setHost和setService中写什么? –

+0

以下代码未给出任何例外情况。 –

+0

它取决于您为服务配置的XMPP域。主机可能是您的IP地址。 –