Skip navigation
65278 Views 23 Replies Latest reply: Feb 6, 2011 4:09 PM by iamsd RSS
stachu2012 Bronze 3 posts since
Oct 28, 2008
Currently Being Moderated

Nov 16, 2008 3:51 AM

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

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?

  • alex_1 Bronze 51 posts since
    Feb 25, 2006

    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)

    ...

    • dimitar Bronze 8 posts since
      Nov 26, 2008

      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.

    • dimitar Bronze 8 posts since
      Nov 26, 2008

      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.

      • Bronze 1 posts since
        Nov 26, 2008

        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)

      • Bronze 2 posts since
        Dec 17, 2008

        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?

      • pinkss Bronze 1 posts since
        Dec 29, 2008

        it really worked:)

      • Bronze 6 posts since
        Jan 5, 2009

        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.

      • kduffie Bronze 7 posts since
        May 14, 2010

        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?

  • Guenther Niess KeyContributor 305 posts since
    Jun 19, 2008

    Fixed SMACK-264 for trunk version on revision 11256.

  • voanirges Bronze 1 posts since
    Feb 23, 2010

    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
  • chrlilje Bronze 1 posts since
    Apr 7, 2010

    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

    • Matt Bronze 5 posts since
      Aug 30, 2010

      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    

      • iamsd Bronze 2 posts since
        Feb 6, 2011

        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;
        }

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points