mardi 30 septembre 2014

smack failed to login on gtalk


Vote count:

0




I'm using smack 4.0.4 and trying to establish a connection with gtalk server but without any success. connection.getHost() and connection.getUser() returns null . Here is my code



ConnectionConfiguration connConfig = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
XMPPTCPConnection connection = new XMPPTCPConnection(connConfig);

try {
connection.connect();
System.out.println("Connected to " + connection.getHost());
} catch (XMPPException ex) {
//ex.printStackTrace();
System.out.println("Failed to connect to " + connection.getHost());
System.exit(1);
} catch (SmackException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
connection.login("user@example.com", "password");
System.out.println("Logged in as " + connection.getUser());

Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);

} catch (XMPPException ex) {
//ex.printStackTrace();
System.out.println("Failed to log in as " + connection.getUser());
System.exit(1);
} catch (SaslException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SmackException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


and the output is



Connected to null
Failed to log in as null


asked 39 secs ago

Doua Beri

1,054






smack failed to login on gtalk

Aucun commentaire:

Enregistrer un commentaire