I am using Smack API trying to connect and login to the Openfire XMPP server which is setup on my laptop (localhost).
XMPPTCPConnectionConfiguration conf = XMPPTCPConnectionConfiguration.builder()
.setServiceName("win10-xps15")
.setHost("192.168.1.100")
.setPort(5222)
.setCompressionEnabled(false)
.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.build();
XMPPTCPConnection connection = new XMPPTCPConnection(conf);
connection.connect();
connection.login("admin", "password");
The connect() method is successful but the login() method fails with a NoResponse (timeout) exception.
Exception in thread "main" org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 5000ms (~5s). Used filter: No filter used or filter was 'null'.
at org.jivesoftware.smack.SmackException$NoResponseException.newWith(SmackException.java:106)
at org.jivesoftware.smack.SmackException$NoResponseException.newWith(SmackException.java:85)
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:250)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.loginNonAnonymously(XMPPTCPConnection.java:374)
at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java:456)
at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java:431)
at MyConnector.main(MyConnector.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Apr 13, 2016 11:45:42 AM org.jivesoftware.smack.AbstractXMPPConnection callConnectionClosedOnErrorListener
WARNING: Connection closed with error
java.lang.NullPointerException
at org.jivesoftware.smack.util.stringencoder.Base64.decode(Base64.java:86)
at org.jivesoftware.smack.sasl.SASLMechanism.challengeReceived(SASLMechanism.java:233)
at org.jivesoftware.smack.SASLAuthentication.challengeReceived(SASLAuthentication.java:328)
at org.jivesoftware.smack.SASLAuthentication.challengeReceived(SASLAuthentication.java:313)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1051)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:948)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:963)
at java.lang.Thread.run(Thread.java:745)
I am running Openfire 3.9.3 on my Windows laptop and the local IP is 192.168.1.100. The version of the smack library is 4.1.6.
Since it is the login() method that fails, I wonder if there is any Openfire server settings related to login/user that I should be aware of?
In addition, I tried to login with the Spark IM client and it could login the local server without problems.
Regards.
More info added below.
I just tried an old version (3.4.1) of smack obtained from the Spark IM github repo with the following code:
ConnectionConfiguration conf =
new ConnectionConfiguration("192.168.1.100", 5222);
XMPPConnection connection = new XMPPConnection(conf);
connection.connect();
connection.login("admin", "password");
Now the code works fine. Both connect() and login() are OK.
But I really want to know why the lastet version of smack does not work as I expect. Because I am considering using smack on Android while the old version does not support Android natively.
m using last version of Smack and login like you, and its working fine. I have no access to my code now, in 3 hours i
ll try to help you – Lucas Ferraz