AnsweredAssumed Answered

Smack4.1.7 No response received within reply timeout

Question asked by Mehta on Jul 26, 2016
Latest reply on Aug 24, 2016 by Mehta

Hello Everyone,

 

When I am trying to connect to xmpp openfire server from my android client I get the following exception:

 

 

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.SASLAuthentication.authenticate(SASLAuthentication.java: 250)

at org.jivesoftware.smack.tcp.XMPPTCPConnection.loginNonAnonymously(XMPPTCPConnect ion.java:374)

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

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

at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection. java:863)

at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.ja va:364)

at com.myapp.xmpp.XmppService.connectAndAuthenticate(XmppService.java:496)

at com.myapp.xmpp.XmppService$2.run(XmppService.java:199)

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

 

The code that I am using to connect is as follows:

 

XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder()
  .setUsernameAndPassword(hashedUserName, getPassword())
  .setServiceName(serviceName)
  .setHost(getCoreServer())
  .setSendPresence(true)
  .setSecurityMode(ConnectionConfiguration.SecurityMode.required)
  .setPort(5222)
  .setResource(getDeviceID());

 

   XMPPTCPConnectionConfiguration config = builder.build();

   xmppConnection = new XMPPTCPConnection(config);

   // Disable the roster
   Roster.getInstanceFor(xmppConnection).setRosterLoadedAtLogin(false);

   ReconnectionManager reconnectionManager = ReconnectionManager.getInstanceFor(xmppConnection);
   reconnectionManager.enableAutomaticReconnection();
   reconnectionManager.setReconnectionPolicy(ReconnectionManager.ReconnectionPolic y.FIXED_DELAY);
   reconnectionManager.setFixedDelay(20);

   PingManager pingManager = PingManager.getInstanceFor(xmppConnection);
   pingManager.registerPingFailedListener(this);
   pingManager.setPingInterval(60);

   // Instantiates a ChatStateManager.
   ChatStateManager.getInstance(xmppConnection
);

 

try {
   Log.i(TAG, "Before xmppConnection connect.....");
   xmppConnection.connect();
   Log.i(TAG, "After xmppConnection connect.....");
} catch (SmackException.AlreadyConnectedException e) {
   e.printStackTrace();
} catch (SmackException e) {
   e.printStackTrace();
} catch (IOException e) {
   e.printStackTrace();
} catch (XMPPException e) {
   e.printStackTrace();
} catch (Exception e) {

  e.printStackTrace();
}

 

I would really appreciate if anyone can help me out on how to solve this issue and what am I doing wrong.

 

Thanks.

Outcomes