I implemented new Smack 4.2 with Ejabberd I'm getting connection closed on error if I don't login or register as I want to create a connection before login or register. The same code is working fine with Openfire server.
I'm getting this error in a few seconds (nearly 30 seconds) when connection is created. Connection XMPPTCPConnection[not-authenticated] (0) closed with error org.jivesoftware.smack.XMPPException$StreamErrorException: connection-timeout You can read more about the meaning of this stream error at http://xmpp.org/rfcs/rfc6120.html#streams-error-conditions
On re-connection it is crashing with this error
FATAL EXCEPTION: Smack Reconnection Manager (0) java.lang.IllegalArgumentException: Username must not be null or empty at org.jivesoftware.smack.util.StringUtils.requireNotNullOrEmpty(StringUtils.java:468) at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java:484) at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java:448) at org.jivesoftware.smack.ReconnectionManager$2.run(ReconnectionManager.java:254) at java.lang.Thread.run(Thread.java:818)
Some lines of code of configuration
if (connection == null || !connection.isConnected()) {
XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration
.builder();
config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
DomainBareJid serviceName = JidCreate.domainBareFrom(Constants.SERVER_NAME);
config.setServiceName(serviceName);
InetAddress inetAddress = InetAddress.getByName(Constants.HOST);
config.setXmppDomain(Constants.SERVER_NAME);
config.setHostAddress(inetAddress);
config.setHost(Constants.HOST);
config.setPort(Constants.PORT);
config.setResource(Constants.RESOURCE);
config.setDebuggerEnabled(true);
SASLAuthentication.blacklistSASLMechanism("PLAIN");
SASLAuthentication.blacklistSASLMechanism("DIGEST-MD5");
SASLAuthentication.unBlacklistSASLMechanism("SCRAM-SHA-1");
XMPPTCPConnection.setUseStreamManagementDefault(true);
connection = new XMPPTCPConnection(config.build());
initializingMessageReceivedListeners();
enableReConnection();
connection.connect();
}
Thanks in advance.