2013-04-21 142 views
1

現在我正在使用ejabberd服務器與Android的XMPP聊天工作。ejabberd服務器中的服務器錯誤沒有響應

當我試圖連接到服務器時,它顯示一個錯誤。但它在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):無法以[email protected]登錄 04-21 20:34:21.932:E/XMPPChatDemoActivity(1929):服務器沒有響應。

回答

2

我找到解決方案如何連接的gtalk和jabber.org與啪3.1.0:

代碼的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("[email protected]", "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服務器。我希望這能解決你的問題。