AnsweredAssumed Answered

BOSH conn.login() giving null pointer exception

Question asked by Sharat on Jun 2, 2017
Latest reply on Jun 5, 2017 by Hiren

Hi,

 

I am using smack 4.20 libraries with ejabberd 17.04.

The ejabberd server http-bind is enabled and works fine with converse.js.

 

But when i try to login using smack, it gives the below error:

 

Jun 02, 2017 9:40:24 PM org.igniterealtime.jbosh.BOSHClient init

INFO: Starting with 1 request processors

21:40:25 RECV (0): <body xmpp:version='1.0' authid='2600567741861848662' xmlns='http://jabber.org/protocol/httpbind' sid='da11ba8772dbeaba769616df4f314e57c6e67653' 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='huaweicrm'/>

Jun 02, 2017 9:40:25 PM org.jivesoftware.smack.SASLAuthentication selectMechanism

WARNING: Server did not report any SASL mechanisms

Exception in thread "main" java.lang.NullPointerException

at java.util.Collections$UnmodifiableCollection.<init>(Collections.java:1051)

at java.util.Collections$UnmodifiableSet.<init>(Collections.java:1122)

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

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.bosh.XMPPBOSHConnection.loginInternal(XMPPBOSHConnection .java:223)

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

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

at com.huawei.universalcrm.server.service.JabberSmackAPI.main(JabberSmackAPI.java: 128)

21:40:25 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</me chanism><mechanism>ANONYMOUS</mechanism></mechanisms><register xmlns='http://jabber.org/features/iq-register'/></stream:features></body>

Jun 02, 2017 9:40:55 PM org.jivesoftware.smack.AbstractXMPPConnection callConnectionClosedOnErrorListener

WARNING: Connection XMPPBOSHConnection[not-authenticated] (0) closed with error

java.lang.NullPointerException

at org.jivesoftware.smack.packet.XMPPError$Type.fromString(XMPPError.java:369)

at org.jivesoftware.smack.util.PacketParserUtils.parseError(PacketParserUtils.java :857)

at org.jivesoftware.smack.bosh.XMPPBOSHConnection$BOSHPacketReader.responseReceive d(XMPPBOSHConnection.java:537)

at org.igniterealtime.jbosh.BOSHClient.fireResponseReceived(BOSHClient.java:1601)

at org.igniterealtime.jbosh.BOSHClient.processExchange(BOSHClient.java:1136)

at org.igniterealtime.jbosh.BOSHClient.processMessages(BOSHClient.java:990)

at org.igniterealtime.jbosh.BOSHClient.access$300(BOSHClient.java:100)

at org.igniterealtime.jbosh.BOSHClient$RequestProcessor.run(BOSHClient.java:1719)

at java.lang.Thread.run(Thread.java:745)

 

 

Jun 02, 2017 9:40:55 PM org.jivesoftware.smack.AbstractXMPPConnection callConnectionClosedOnErrorListener

WARNING: Connection XMPPBOSHConnection[not-authenticated] (0) closed with error

org.igniterealtime.jbosh.BOSHException: Terminal binding condition encountered: remote-stream-error  (Encapsulated transport protocol error.)

at org.igniterealtime.jbosh.BOSHClient.checkForTerminalBindingConditions(BOSHClien t.java:1385)

at org.igniterealtime.jbosh.BOSHClient.processExchange(BOSHClient.java:1161)

at org.igniterealtime.jbosh.BOSHClient.processMessages(BOSHClient.java:990)

at org.igniterealtime.jbosh.BOSHClient.access$300(BOSHClient.java:100)

at org.igniterealtime.jbosh.BOSHClient$RequestProcessor.run(BOSHClient.java:1719)

at java.lang.Thread.run(Thread.java:745)

 

The following is the code which i have written for the same:

 

BOSHConfiguration config = BOSHConfiguration.builder().setHost("10.18.246.229").setXmppDomain("huaweicrm")

.setPort(Integer.parseInt("5280")).setFile("/http-bind/").setSecurityMode(Connec tionConfiguration.SecurityMode.disabled)

.setDebuggerEnabled(true).build();

 

AbstractXMPPConnection con = new XMPPBOSHConnection(config);

con.connect();

con.login("admin", "admin");

 

Please let me know what am i doing wrong.

 

Thanks!

Outcomes