无法使用smack api连接到ejabberd服务器

时间:2015-09-21 09:26:19

标签: ejabberd smack

我正在尝试连接到ejabberd服务器并使用Smack Api。下面是连接到服务器的代码。设置用户名,主机和localhost服务后,我试图在连接时显示Toast。在调试时,既没有显示Toast也没有任何异常......请看下面的代码

       XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
                .setUsernameAndPassword("alien@localhost", "alien")
                .setServiceName("localhost")
                .setHost("192.168.1.xx")
                .setPort(5222)
                         .setDebuggerEnabled(true)
                .build();

        AbstractXMPPConnection conn2 = new XMPPTCPConnection(config);
        try {
            conn2.connect();
            conn2.login();
            if(conn2.isConnected())
           {
    Toast.makeText(ChatClient.this,"isConnected",Toast.LENGTH_LONG).show();
          }
   else
     {
        Toast.makeText(ChatClient.this,"Failed",Toast.LENGTH_LONG).show();
      }

以下是我在项目中使用的依赖项

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile "org.igniterealtime.smack:smack-android:4.1.0"
    // Optional for XMPPTCPConnection
    compile "org.igniterealtime.smack:smack-tcp:4.1.0"
    // Optional for XMPP-IM (RFC 6121) support (Roster, Threaded Chats, …)
    compile "org.igniterealtime.smack:smack-im:4.1.0"
    // Optional for XMPP extensions support

    compile "org.igniterealtime.smack:smack-android-extensions:4.1.0"
}

我的域名是(192.168。***。2 *:5280 / admin)..提前谢谢你:)

0 个答案:

没有答案