Problem with org.jivesoftware.smack.sasl.SASLErrorException: SASLError using DIGEST-MD5: not-authorized


I’m trying to connect via client I am working on to the local instance of the Openfire server.

While trying to login to the server I’m getting an error.

I am able to connect to the server with my credentials, through Adium, so it’s not a problem of the credentials.

I am using following dependencies:

compile ‘org.igniterealtime.smack:smack-tcp:4.1.0-beta2’

compile ‘org.igniterealtime.smack:smack-core:4.1.0-beta2’

compile ‘org.dnsjava:dnsjava:2.0.6’

compile ‘org.igniterealtime.smack:smack-android:4.1.0-beta2’

compile ‘org.igniterealtime.smack:smack-extensions:4.1.0-beta2’

Here is the error message:

10 12:48:12.049 2391-2466/ D/SMACK﹕ SENT (0): <stream:stream xmlns=‘jabber:client’ to=‘’ xmlns:stream=‘’ version=‘1.0’ xml:lang=‘en’>

02-10 12:48:12.057 2391-2467/ D/SMACK﹕ RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream=“” xmlns=“jabber:client” from=“iliyan.local” id=“648898d9” xml:lang=“en” version=“1.0”>

02-10 12:48:12.061 2391-2467/ D/SMACK﹕ RECV (0): stream:featuresPLAINANONYMOUSCRAM-MD5DIGEST-MD5</mech anism>zlib</stream:features>

02-10 12:48:12.071 2391-2465/ D/ChatController﹕ connected: org.jivesoftware.smack.tcp.XMPPTCPConnection@46395b2

02-10 12:48:12.074 2391-2466/ D/SMACK﹕ SENT (0): =

02-10 12:48:12.079 2391-2467/ D/SMACK﹕ RECV (0): cmVhbG09ImlsaXlhbi5sb2NhbCIsbm9uY2U9Im 9PT3ZTWnRnSWlXWkZ2aHU5b09kRzhrT05veUt0MG03SVphVkF2N2IiLHFvcD0iYXV0aCIsY2hhcnNldD 11dGYtOCxhbGdvcml0aG09bWQ1LXNlc3M=

02-10 12:48:12.085 2391-2466/ D/SMACK﹕ SENT (0): dXNlcm5hbWU9InRlc3QiLHJlYWxtPSIxOTIuMT Y4LjE5LjUwIixub25jZT0ib09PdlNadGdJaVdaRnZodTlvT2RHOGtPTm95S3QwbTdJWmFWQXY3YiIsY2 5vbmNlPSIwblZXVE43MU1ISFhxejZLZHRwVm9PMUZ4Mkcyd1BuRyIsbmM9MDAwMDAwMDEscW9wPWF1dG gsZGlnZXN0LXVyaT0ieG1wcC8xOTIuMTY4LjE5LjUwIixyZXNwb25zZT02YjgyMzliODkwMzgwN2VhMz k2MmM2Y2U5NzA3YWZlNixjaGFyc2V0PXV0Zi04

02-10 12:48:12.090 2391-2467/ D/SMACK﹕ RECV (0):

02-10 12:48:12.094 2391-2469/ W/System.err﹕ org.jivesoftware.smack.sasl.SASLErrorException: SASLError using DIGEST-MD5: not-authorized

02-10 12:48:12.095 2391-2469/ W/System.err﹕ at org.jivesoftware.smack.SASLAuthentication.authenticationFailed(SASLAuthenticati

02-10 12:48:12.095 2391-2469/ W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC

02-10 12:48:12.095 2391-2469/ W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPCon

02-10 12:48:12.095 2391-2469/ W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$

Here is my implementation:

final XMPPTCPConnectionConfiguration connectionConfiguration = XMPPTCPConnectionConfiguration.builder()







mConnection = new XMPPTCPConnection(connectionConfiguration);


mConnection.login(“test”, “12345678”);

I tried changing the username to test@SERVER_ADDRESS, no effect.

How can I fix this problem?

compile 'org.dnsjava:dnsjava:2.0.6’
Although likely unrelated: Why did you add dnsjava? Smack uses minidns on Android.

Is SERVER_ADDRESS set to the XMPP domain?

You also likely can omit the server port if the XMPP service listens on the default XMPP client port or if you have setup your DNS SRV correctly.

final XMPPTCPConnectionConfiguration connectionConfiguration = XMPPTCPConnectionConfiguration.builder()


.setHost(SERVER_ADDRESS) ----missing in your code

service name may not be used for resolving purpose

Good stuff man.

public final static String SERVER_ADDRESS = “”;

public final static String SERVER_HOST = “local.server”;

final XMPPTCPConnectionConfiguration connectionConfiguration = XMPPTCPConnectionConfiguration.builder()








You both were right.

It seems that you can connect to the server with Address, but you need Host for authentication on the server.

Is that right?

It seems that you can connect to the server with Address, but you need Host for authentication on the server.

Is that right?

No, if the XMPP service is configured properly, i.e. with DNS SRV records, then you only need to the XMPP domain set as service name. Smack will use the information from the DNS SRV records to decide which host/port to connect to. This will also work if the XMPP domain’s A RR resolves to the host that serves as XMPP server for the domain. Only if this is not the case, you have to manually specify the host and port.

Hi even i am facing the same issues.

This is how i am connecting to openfire and then performing login:

AndroidConnectionConfiguration connConfig = new AndroidConnectionConfiguration(HOST, PORT,SERVICE);







In most of the cases this is working fine but randomly it gives me an error during login i.e. No Response from server with Non-SASL Authentication message.

In addition, when the app is kept idle and no operation is being performed, my session from the openfire gets cleared and connection gets disconnected. Please assist with a feasible solution for the two reported issues. Your help is highly appreciated.