Asutosh11 / asmack

Automatically exported from code.google.com/p/asmack
Other
0 stars 0 forks source link

ERROR/XMPPClient(389): SASL authentication failed using mechanism DIGEST-MD5: and connConfig.setSASLAuthenticationEnabled(false); #78

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
i am creating facebook chat app.
1.i am creating first time any chat application
2.i can't u'stand what to do for error
3.SASL authentication failed using digest md 5 nad can't login with 
username@chat.facebook.com

What is the expected output?
login into fb with jeberid and show friend list

What do you see instead? (Please attach a debug enabled logcat)
no
What version of aSmack / Android / Device do you use?
2.1.1
What server do you use? Is there a public server to reproduce the problem?

What else might help us to reproduce and hunt down the problem?

Original issue reported on code.google.com by jethava....@gmail.com on 18 Sep 2012 at 6:45

Attachments:

GoogleCodeExporter commented 8 years ago
have the same problem

Original comment by Pablote...@gmail.com on 4 Feb 2013 at 12:35

GoogleCodeExporter commented 8 years ago

I have the following client code (tried with both user, and 
user@chat.myserver.com): 

            XMPPConnection jabberConnection;
            ConnectionConfiguration cc = new ConnectionConfiguration("chat.myserver.com",5222);

            jabberConnection = new XMPPConnection(cc);
            jabberConnection.connect();
            SASLAuthentication.supportSASLMechanism("PLAIN", 0);

            jabberConnection.login(User.username + "-fb",User.username + "-fb");

and the exception I get is:

02-20 18:17:32.855: E/SERVICE(233): com.packet.android: jabber connection failed
02-20 18:17:32.975: E/Updates(233): null
02-20 18:17:32.975: E/Updates(233): SASL authentication failed using mechanism 
PLAIN: 
02-20 18:17:32.975: E/Updates(233):     at 
org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:3
41)
02-20 18:17:32.975: E/Updates(233):     at 
org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:207)
02-20 18:17:32.975: E/Updates(233):     at 
org.jivesoftware.smack.Connection.login(Connection.java:355)
02-20 18:17:32.975: E/Updates(233):     at 
com.packet.service.android.Updates.onCreate(Updates.java:93)
02-20 18:17:32.975: E/Updates(233):     at 
android.app.ActivityThread.handleCreateService(ActivityThread.java:2780)
02-20 18:17:32.975: E/Updates(233):     at 
android.app.ActivityThread.access$3200(ActivityThread.java:119)
02-20 18:17:32.975: E/Updates(233):     at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1917)
02-20 18:17:32.975: E/Updates(233):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
02-20 18:17:32.975: E/Updates(233):     at android.os.Looper.loop(Looper.java:123)
02-20 18:17:32.975: E/Updates(233):     at 
android.app.ActivityThread.main(ActivityThread.java:4363)
02-20 18:17:32.975: E/Updates(233):     at 
java.lang.reflect.Method.invokeNative(Native Method)
02-20 18:17:32.975: E/Updates(233):     at 
java.lang.reflect.Method.invoke(Method.java:521)
02-20 18:17:32.975: E/Updates(233):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
02-20 18:17:32.975: E/Updates(233):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
02-20 18:17:32.975: E/Updates(233):     at dalvik.system.NativeStart.main(Native 
Method)

If you check the source code:

 /**
     * Performs SASL authentication of the specified user. If SASL authentication was successful
     * then resource binding and session establishment will be performed. This method will return
     * the full JID provided by the server while binding a resource to the connection.<p>
     *
     * The server may assign a full JID with a username or resource different than the requested
     * by this method.
     *
     * @param username the username that is authenticating with the server.
     * @param password the password to send to the server.
     * @param resource the desired resource.
     * @return the full JID provided by the server while binding a resource to the connection.
     * @throws XMPPException if an error occures while authenticating.
     */
    public String authenticate(String username, String password, String resource)
            throws XMPPException {
        // Locate the SASLMechanism to use
        String selectedMechanism = null;
        for (String mechanism : mechanismsPreferences) {
            if (implementedMechanisms.containsKey(mechanism) &&
                    serverMechanisms.contains(mechanism)) {
                selectedMechanism = mechanism;
                break;
            }
        }
        if (selectedMechanism != null) {
            // A SASL mechanism was found. Authenticate using the selected mechanism and then
            // proceed to bind a resource
            try {
                Class<? extends SASLMechanism> mechanismClass = implementedMechanisms.get(selectedMechanism);
                Constructor<? extends SASLMechanism> constructor = mechanismClass.getConstructor(SASLAuthentication.class);
                currentMechanism = constructor.newInstance(this);
                // Trigger SASL authentication with the selected mechanism. We use
                // connection.getHost() since GSAPI requires the FQDN of the server, which
                // may not match the XMPP domain.
                currentMechanism.authenticate(username, connection.getServiceName(), password);

                // Wait until SASL negotiation finishes
                synchronized (this) {
                    if (!saslNegotiated && !saslFailed) {
                        try {
                            wait(30000);
                        }
                        catch (InterruptedException e) {
                            // Ignore
                        }
                    }
                }

                if (saslFailed) {
                    // SASL authentication failed and the server may have closed the connection
                    // so throw an exception
                    if (errorCondition != null) {
                        throw new XMPPException("SASL authentication " +
                                selectedMechanism + " failed: " + errorCondition);
                    }
                    else {
                        throw new XMPPException("SASL authentication failed using mechanism " +
                                selectedMechanism);
                    }
                }

                if (saslNegotiated) {
                    // Bind a resource for this connection and
                    return bindResourceAndEstablishSession(resource);
                }
                else {
                    // SASL authentication failed so try a Non-SASL authentication
                    return new NonSASLAuthentication(connection)
                            .authenticate(username, password, resource);
                }
            }
            catch (XMPPException e) {
                throw e;
            }
            catch (Exception e) {
                e.printStackTrace();
                // SASL authentication failed so try a Non-SASL authentication
                return new NonSASLAuthentication(connection)
                        .authenticate(username, password, resource);
            }
        }
        else {
            // No SASL method was found so try a Non-SASL authentication
            return new NonSASLAuthentication(connection).authenticate(username, password, resource);
        }
    }

What could the problem be? 

Thank you

Original comment by Pablote...@gmail.com on 20 Feb 2013 at 6:54