23 Replies Latest reply on Feb 6, 2011 4:09 PM by iamsd

    Can't connect to XMPP server in Smack 3.1.0 beta release

    Bronze

      Hello, a have strange problem and i don't know the reson.

      It's about basic Smack code - making connetion to XMPP server

       

           xmppConnection = new XMPPConnection("jabberpl.org");
           xmppConnection.connect();
           xmppConnection.login("login", "passwd");
           initialize();


      With version 3.0.4 of Smack everything goes right. The connection is made, the user is logged in.

      When I use 3.1.0b the third line couse an error:

       

      "SASL authentication failed using mechanism DIGEST-MD5:"

       

      Has anybody heard about similar problem? any suggestions?

        • Re: Can't connect to XMPP server in Smack 3.1.0 beta release
          alex_1 Bronze

          Same problem while trying to connect to GoogleTalk

           

          "SASL authentication failed using mechanism PLAIN"

           

          PLEASE fix this ASAP!

           

          SASL authentication failed using mechanism PLAIN:
              at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 325)
              at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:395)
              at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:349)

          ...

            • Re: Can't connect to XMPP server in Smack 3.1.0 beta release
              dimitar Bronze

              I have the same problem too. I tested smack 3.1.0 and i can connect only to my local Openfire server, i installed local ejabberd server and this error ocurr:

               

              java.lang.NullPointerException

              at org.jivesoftware.smack.util.Base64.encodeBytes(Base64.java:636)

              at org.jivesoftware.smack.sasl.SASLMechanism.challengeReceived(SASLMechanism.java: 152)

              at org.jivesoftware.smack.SASLAuthentication.challengeReceived(SASLAuthentication. java:492)

              at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:338)

              at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)

              at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:76)

               

               

              I get the same error when i try to connect to jabber.org. It seams Smack 3.1.0 wokrs only when you connect to openfire server. I hope this will be fixed soon.

              • Re: Can't connect to XMPP server in Smack 3.1.0 beta release
                dimitar Bronze

                I found solution how to connect to gtalk and jabber.org with Smack 3.1.0:


                For gtalk here is the code:

                 

                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("some.account@gmail.com", "password", "resource");

                 

                     // See if you are authenticated

                     System.out.println(connection.isAuthenticated());

                 

                } catch (XMPPException e1) {

                     e1.printStackTrace();

                }

                 

                 

                For jabber.org here is the code:

                 

                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();

                }



                 

                With this code i can now connect to my local ejabberd and openfire server. I hope this will solve your problems.

                  • Re: Can't connect to XMPP server in Smack 3.1.0 beta release
                    Bronze

                    Great. The solution works.

                    Tested without proxy for Gtalk as wel as Jabber.org.

                     

                    Thanx dimitar

                    -------

                     

                    Can't get in from behind proxyl!!

                    Getting following exception:

                     

                    not-allowed(405) Connection must be encrypted.
                        at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication .java:78)
                        at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 352)
                        at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:395)
                        at ClientTestProxy.main(ClientTestProxy.java:36)

                    • Re: Can't connect to XMPP server in Smack 3.1.0 beta release
                      Bronze

                      Hi!

                      The same problem: SASL authentication failed using mechanism DIGEST-MD5.

                      Is it really one solution!? So now we have to check all the servers for good login name (with or without you:)?

                      I also had (when i tryed to connect to another server) :

                       

                      java.lang.NullPointerException
                              at org.jivesoftware.smack.util.Base64.encodeBytes(Base64.java:636)
                              at org.jivesoftware.smack.sasl.SASLMechanism.challengeReceived(SASLMechanism.java: 152)
                              at org.jivesoftware.smack.SASLAuthentication.challengeReceived(SASLAuthentication. java:492)
                              at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:338)
                              at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
                              at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:76)

                       

                      The funny thing is when i put my password in md5 it disappear (I only had "SASL authentication failed using mechanism DIGEST-MD5").

                       

                      Please help, the sooner the better, maybe in 3.1.1?

                      • Re: Can't connect to XMPP server in Smack 3.1.0 beta release
                        Bronze

                        I tried the gtalk code and it worked. But the code for jabber.org fails with this error:

                         

                        SASL authentication failed using mechanism PLAIN:
                            at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 325)
                            at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:395)
                            at com.my.xmpp.XmppTest.main(XmppTest.java:30)

                         

                        I made sure that I was using the ID w/o domain name. Are there multiple binary releases

                        of smack 3.1.0 beta? I'm using the version I just downloaded today.

                        • Re: Can't connect to XMPP server in Smack 3.1.0 beta release
                          kduffie Bronze

                          I'm using the latest smack code from SVN (as of last Friday, May 14, 2010) and I'm unable to get connected to Jabber.org using exactly the code fragment in the post above (with only the username and password changed).  The code works for connecting to GoogleTalk, but not Jabber.org.  I get an exception on the login call, returning the classic SASL authentication PLAIN failed:  invalid-authzid.  I've decoded the BASE-64 and it looks correct as far as I can see.

                           

                          Has something changed between the 3.1.0 release and the current code that may have broken this?

                           

                          (Note that I've checked to make sure that Psi and Spark clients are able to connect to jabber.org using the same credentials.)

                           

                          Anyone have any idea what is going on?

                      • Re: Can't connect to XMPP server in Smack 3.1.0 beta release
                        Guenther Niess KeyContributor

                        Fixed SMACK-264 for trunk version on revision 11256.

                        • Re: Can't connect to XMPP server in Smack 3.1.0 beta release
                          Bronze

                          Hi guys, I read carefully all you wrote, but couldn't make anything here working fine, so about the solution, first you should download asmack library which is library for smack on Android, and Facebook chat works fine on this, where HOST= chat.facebook.com, domain is same and username/password is your username and password on facebook WITHOUT @chat.facebook.com if domain is entered as host(see up).But this can make troubles with Gtalk, because Gtalk requires "PLAIN" authentication and here is MD5 by default, so what?

                          No overriding methods , extending classes and so on just when initializing connection add this line

                           

                           

                          XMPPConnection connection = new XMPPConnection(connConfig);
                                         connConfig.setSASLAuthenticationEnabled(false);/// for gtalk and true for Facebook(or escape this line for Facebook with one IF clause)
                                                            Best regards, and please don't post fake solutions guys, isn't ethic make it work first Filip
                          • Re: Can't connect to XMPP server in Smack 3.1.0 beta release
                            Bronze

                            Solution for google talk: Use good passwords!

                             

                             

                            I had this problem. But the strangeness was, that one account worked, and other accounts gave the error.

                             

                            The password strength of the account that worked was "Strong"

                            - and the pw strength of the accoutn that did not work was "fair".

                             

                            I changed the password to a strong one for the not-working account, and that did the trick.

                             

                            There is probably a good reason why. :-)

                             

                            Best regards

                            Christian Liljedahl

                              • Re: Can't connect to XMPP server in Smack 3.1.0 beta release
                                Matt Bronze

                                Has anyone gotten this to work at all for the android platform using the asmack libs? I fail on MD-5 sasl authentication no matter what I do    

                                  • Re: Can't connect to XMPP server in Smack 3.1.0 beta release
                                    iamsd Bronze

                                    After hours of trial & error, I finally found a way to make all my gtalk accounts work with asmack (3.1.0) !

                                     

                                    Problem was, that only some of my google accounts worked, while others didn't (wrong password/id exception)

                                    Some Accounts work when using "gmail.com" as ServiceName, while others only work when using "googlemail.com" !

                                     

                                    --> Workaround: Try to connect with "gmail.com" first, if an exception is thrown, try to connect again with "googlemail.com"

                                     

                                    [...]

                                    mConConfig = new ConnectionConfiguration("talk.google.com", "5222", "gmail.com");

                                    mConConfig.setSASLAuthenticationEnabled(false);

                                    XMPPConnection xmppCon = new XMPPConnection(mConConfig);

                                    try{
                                                    xmppCon.connect();
                                    }catch(XMPPException e){
                                                    return;
                                    }
                                    try{
                                                    xmppCon.login(mUsername, mPassword, mResource);
                                    }catch(XMPPException e){

                                                    if(mService.equalsIgnoreCase("gmail.com")){
                                                        mConConfig.setServiceName("googlemail.com");
                                                        connect();
                                                        return;
                                                    }else if(mService.equalsIgnoreCase("googlemail.com")){
                                                        mConConfig.setServiceName("gmail.com");
                                                        connect();
                                                        return;
                                    }