Getting Server did not report any SASL mechanisms sometimes

Hi,

I am getting this error quit often.
What is the root cause for this?

Error : ‘Server did not report any SASL mechanisms’

I am trying to login to a chat but sometimes I get this error. The login credentials are fine, that was the first thing I checked. I get this error not all the time (for the same user), sometime the login succeeds but sometime I get this error (without changing the credentials). What should be the second thing I need to check?

Any help is appreciated.

Thanks,

Are you using version 4.1.4 of Openfire? If so, you can check on the admin console as to which SASL mechanisms are available.

https://localhost:9091/reg-settings.jsp

Hi @Daryl Herzmann

We are using ejabberd 17.03. Following are the SASL mechanisms are available:

PLAIN

X-OAUTH2

SCRAM-SHA-1

Thanks

Getting NPE with this warning message ‘Server did not report any SASL mechanisms’:

java.lang.NullPointerException: set == null

at java.util.Collections.unmodifiableSet(Collections.java:2321)

at org.jivesoftware.smack.ConnectionConfiguration.getEnabledSaslMechanisms(Connect ionConfiguration.java:476)

at org.jivesoftware.smack.SASLAuthentication.selectMechanism(SASLAuthentication.ja va:359)

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 191)

at org.jivesoftware.smack.tcp.XMPPTCPConnection.loginInternal(XMPPTCPConnection.ja va:385)

at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :491)

Same issue here. All I’m doing is this:

connection.connect();
connection.login();

Using Smack 4.2.4, over BOSH, server is ejabberd 18.03.

13:32:34 RECV (0): <body xmpp:version='1.0' authid='14015981785299716397' xmlns='http://jabber.org/protocol/httpbind' sid='b52d7913c6a020fdc5faaacd9fee51c5306990d1' wait='60' ver='1.11' polling='2' inactivity='30' hold='1' xmpp:restartlogic='true' requests='2' secure='true' maxpause='120' xmlns:xmpp='urn:xmpp:xbosh' xmlns:stream='http://etherx.jabber.org/streams' from='xmpp.example.com'/>
Kvě 10, 2018 1:32:34 ODP. org.jivesoftware.smack.SASLAuthentication selectMechanism
WARNING: Server did not report any SASL mechanisms
13:32:34 RECV (0): <body xmlns='http://jabber.org/protocol/httpbind' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>X-OAUTH2</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms><register xmlns='http://jabber.org/features/iq-register'/></stream:features></body>

Features/SASL mechanisms are some times inside the initial payload from server but some times not. ConnectionListener also calls connected() too early (for login).

Add libraryDependencies += "org.igniterealtime.smack" % "smack-sasl-provided" % "4.3.1" to your dependencies. After this it works as expected.

If this solves an issue for you, then you probably did not follow the instructions of Smack’s README. Especially the part that you should either declare a dependency to smack-android or smack-java7 (depending on your target platform).