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?

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)

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.

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.

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)

Glad I can help

thanks you alot dimitar. i solved that problem in my application. could you send me the voice application which done on Smack-Jingle API. sandun1234u@yahoo.co.uk

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?

I have an account at Jabber.org and I’m seeing the same stack-trace when I try to connect. I looked through the source code and there seems to be an error in SASLMechanism.java. Right before line 152, where it tries to encode the response byte-array, it receives the response from evaluating the challenge byte-array. According to Java’s documentation on SaslClient.evaluateChallenge, returning a null byte-array is legal if the challenge succeeded. A null byte array passed into Base64.encodeBytes causes it to crash since it tries to get a length attribute (Base64.java:636) of the input array. I was able to make it work by applying the attached patch to SASLMechanism.java and putting the compiled class into an existing smack.jar file.
SASLMechanism.patch (847 Bytes)

Thank you chromus. I hope Smack 3.1.1 will solve this issue.

it really worked:)

I am using FreeProxy 3.92 Build 1644 (download link http://www.handcraftedsoftware.org/index.php?page=4&action=category&cat_id=2 ), and it works ok. Try it locally on your system, with ProxyInfo class, like this:

if you are using HTTP Proxy type you have to put null for username and password

ProxyInfo proxy = new ProxyInfo(ProxyType.HTTP, “proxy.host”, proxy.port, null, null);

if you are using SOCKS4/5 proxy then your proxy info should be like this (you can put empty string “” for usename and password if your proxy is without authentication)

ProxyInfo proxy = new ProxyInfo(ProxyType.SOCKS4/ProxyType.SOCKS5, “proxy.host”, proxy.port, “username”, “password”);

Then put the proxy object in your ConnectionConfiguration:

ConnectionConfiguration connConf = new ConnectionConfiguration(“jabber.server”, jabber.port, “jabber.service”, proxy); (jabber.service is usually same as jabber.server)

I recomend first you read the help for FreeProxy, and with FreeProxy you can establish local HTTP/SOCKS4/SOCKS5 proxy server, and you can test it.

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.

for jabber.org try the foll. code

ConnectionConfiguration cc = new ConnectionConfiguration(“jabber.org”, 5222);

Then the rest of the code is the same.

Hope this helps, Cheers,

Earlence

@earlenceferns, I tried your suggestion (by removing the third argument) and I got the same error …


for jabber.org try the foll. code

ConnectionConfiguration cc = new ConnectionConfiguration(“jabber.org”, 5222);

Edit: there was a problem with my account. I tried another account and it worked. Thanks for the help!

Hello everybody…

Forget about it, the problem is elsewhere.

But i’ll probably come back

Thanks for your help

Good patch!

Also, SASLMechanism.java line 149 calls sc.evaluateChallange(null), but the javadoc of evaluateChallenge says:

challenge The non-null challenge sent from the server. The challenge array may have zero length.”

This should be changed to:

sc.evaluateChallenge(new byte[0]);

Fixed SMACK-264 for trunk version on revision 11256.

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

Any timeframe for a 3.1.1 release?

IMO this is a quite serious regression (as it worked with 2.x) and its known and fixed since more than a year, but still no release?