2013-04-21 1 views
1

Теперь я работаю с XMPP-чатом для Android, используя ejabberd-сервер.Отсутствие ответа от ошибки сервера на сервере 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. Надеюсь, это решит ваши проблемы.