I m try to connect with Xmpp server,But i m getting exception
Login exception SASL authentication failed using mechanism DIGEST-MD5
i use this code ,can any one help me,or code
try {
if (xmppConnection == null) {
ConnectionConfiguration config = new ConnectionConfiguration(
SERVER_HOST, SERVER_PORT, SERVICE_NAME);
xmppConnection = new XMPPConnection(config);
System.out.println("xmppConnection"+xmppConnection);
}
if (!xmppConnection.isConnected()) {
xmppConnection.connect();
System.out.println("Connecting");
}
System.out.println("facebook id get xmpp "+username);
if (!xmppConnection.isAuthenticated()) {
xmppConnection.login(username, "123");
System.out.println("User is authenticated ");
}
Presence presence = new Presence(Presence.Type.available);
xmppConnection.sendPacket(presence);
} catch (Exception e) {
System.out.println("Login exception "+e);
e.printStackTrace();
}
In the Openfire configuration it is machinename.domain.com
This SASL mechanism uses also the Xmpp Domain name for authentication, not only username and password. This is why authentication fails.
mean your username & password must be like:
username: abc111@domain.com (whatever your domain name)
password: abcabc111
for more detail check this conversation.
I am using below code in my, its working fine in here..
try {
ConnectionConfiguration connConfig = new ConnectionConfiguration("HOST_IP", Integer.parseInt("PORT_NO"));
XMPPConnection connection = new XMPPConnection(connConfig);
connection.connect();
try {
// Login
connection.login("USER_NAME", "PASSWORD");
// Set the status to available
Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);
xmppClient.setConnection(connection);
} catch (XMPPException ex) {
Log.w("XMPPClient", "[SettingsDialog] Failed to log in as " + username);
Log.w("XMPPClient", ex.toString());
xmppClient.setConnection(null);
}
} catch (XMPPException ex) {
Log.w("XMPPClient", "[SettingsDialog] Failed to connect to " + connection.getHost());
Log.w("XMPPClient", ex.toString());
xmppClient.setConnection(null);
}
And I have also added smack.jar file.
Please check below post, i think it might help you..
https://stackoverflow.com/a/6659403/1849482
And many users are getting this error in login. check below links for More Information..
http://community.igniterealtime.org/thread/44219
http://code.google.com/p/asmack/issues/detail?id=33
asmack uses Novell's Open LDAP DigestMD5SaslClient.java which does not support the escape of backslash ('\') and double-quote ('"') for SASL. According to XEP-0106, user name "user@company.com" should be encoded as "user\040company.com". Fully complying with SASL spec, it should be encoded as "user\\040company.com", but asmack didn't. If your XMPP server (e.g. Openfire) uses Java's SASL implementation, it will have a mismatch. Smack 3.x uses Java's SASL implementation, so it works fine. Smack 4.x is supposed to replace asmack, but I don't know if Smack 4.x uses Novell or Java SASL implementation.
BTW, this problem exists in iOS xmppframework as well.
If you are interested in my fix, I'll post it somewhere.
Here is the link to the revised DigestMD5SaslClient.java with the escape quoted string.