【问题标题】:No response from the server error in ejabberd serverejabberd 服务器中的服务器错误没有响应
【发布时间】:2013-04-21 15:15:57
【问题描述】:

现在我正在使用 ejabberd 服务器处理适用于 Android 的 XMPP-chat。

当我尝试连接到服务器时,它显示错误。但它在 openfire 服务器上运行良好。

我正在使用smack library

错误日志如下:

04-21 20:34:16.824: I/XMPPChatDemoActivity(1929): [SettingsDialog] 连接到 10.0.2.2 04-21 20:34:21.932: E/XMPPChatDemoActivity(1929): 以 test3@eworks.com 登录失败 04-21 20:34:21.932:E/XMPPChatDemoActivity(1929):服务器没有响应。

【问题讨论】:

    标签: android xmpp ejabberd smack


    【解决方案1】:

    我找到了如何使用 Smack 3.1.0 连接到 gtalk 和 jabber.org 的解决方案:

    GTalk 代码:

    ConnectionConfiguration cc = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
    XMPPConnection connection = new XMPPConnection(cc);
    try {
         connection.connect();
    
         // You have to put this code before you login
         SASLAuthentication.supportSASLMechanism("PLAIN", 0);
    
         // You have to specify your gmail addres WITH @gmail.com at the end
         connection.login("some.account@gmail.com", "password", "resource");
    
         // See if you are authenticated
         System.out.println(connection.isAuthenticated());
    
    } catch (XMPPException e1) {
         e1.printStackTrace();
    }
    

    对于 jabber.org,代码如下:

    ConnectionConfiguration cc = new ConnectionConfiguration("jabber.org", 5222, "jabber.org");
    XMPPConnection connection = new XMPPConnection(cc);
    try {
         connection.connect();
    
         // You have to put this code before you login
         SASLAuthentication.supportSASLMechanism("PLAIN", 0);
    
         // You have to specify your Jabber ID addres WITHOUT @jabber.org at the end
         connection.login("your.jabber", "password", "resource");
    
         // See if you are authenticated
         System.out.println(connection.isAuthenticated());
    
    } catch (XMPPException e1) {
         e1.printStackTrace();
    }
    

    使用此代码,我现在可以连接到我的本地 ejabberd 和 openfire 服务器。我希望这能解决您的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-13
      • 1970-01-01
      • 2016-12-27
      • 2023-03-13
      • 2018-02-19
      • 2014-06-04
      • 2011-08-22
      • 2017-01-09
      相关资源
      最近更新 更多