powered by Jive Software

Smack4.1.7 No response received within reply timeout

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.

Please show us a trace of the login sequence. More information on how the log is obtained can be found here How to ask for help, report an issue and possible solve the problem yourself · igniterealtime/Smack Wiki · GitHub

Hi Flow,

Thanks for your prompt reply. After testing the app a little more I realized that I get this exception when I try force reconnection as soon as the goes online from airplane mode. In the normal workflow, I don’t get this exception. I want my app to support offline mode so I have to make sure that there is a smooth transition from offline to online mode. So I use airplane mode to test this scenario.

I am using reconnection manager to handle reconnecting at a fixed delay of 20 seconds. I force reconnect because I don’t want the user to wait 20 seconds for the xmpp reconnection if the user is already in the app. So I would rely on reconnection manager to reconnect only when the app is in background. I hope this helps in understanding what I am trying to do here.

I am posting the stack trace again with the debug mode enabled.

07-26 13:55:45.154 com.myapp.xmpptest I/XmppService: Network state changed. Network connected.

07-26 13:55:45.154 com.myapp.xmpptest I/XmppService: Before xmppConnection connect…

07-26 13:55:45.174 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 14

07-26 13:55:45.324 com.myapp.xmpptest D/SMACK: SENT (0): <stream:stream xmlns=‘jabber:client’ to=‘myapp.com’ xmlns:stream=‘http://etherx.jabber.org/streams’ version=‘1.0’ from=‘eaf60f002867230766bb74b4419dffca@myapp.com’ xml:lang=‘en’>

07-26 13:55:45.404 com.myapp.xmpptest D/SMACK: RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream=“http://etherx.jabber.org/streams” xmlns=“jabber:client” from=“myapp.com” id=“bde2ec9” xml:lang=“en” version=“1.0”>

07-26 13:55:45.484 com.myapp.xmpptest D/SMACK: RECV (0): stream:featuresPLAIN</mechanis ms></stream:features>

07-26 13:55:45.484 com.myapp.xmpptest D/SMACK: SENT (0):

07-26 13:55:45.564 com.myapp.xmpptest D/SMACK: RECV (0):

07-26 13:55:46.174 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 13

07-26 13:55:46.194 com.myapp.xmpptest D/SMACK: SENT (0): <stream:stream xmlns=‘jabber:client’ to=‘myapp.com’ xmlns:stream=‘http://etherx.jabber.org/streams’ version=‘1.0’ from=‘eaf60f002867230766bb74b4419dffca@myapp.com’ xml:lang=‘en’>

07-26 13:55:46.274 com.myapp.xmpptest D/SMACK: RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream=“http://etherx.jabber.org/streams” xmlns=“jabber:client” from=“myapp.com” id=“bde2ec9” xml:lang=“en” version=“1.0”>stream:featuresPLAIN</mechanis ms>zlib</stream:features>

07-26 13:55:46.284 com.myapp.xmpptest D/xmppTest: XmppConnectionListener connectionConnected()

07-26 13:55:46.284 com.myapp.xmpptest D/SMACK: XMPPConnection connected (0)

07-26 13:55:46.284 com.myapp.xmpptest D/SMACK: SENT (0): HJKSHGFJHJGKHDJHGJEHJKRHGJKFDHGhjshjkghruiehskrjgbjkeh5j4568o gjkfhdsgh589wwghjfdghsuHJKSHFIREHGHRUEIghgfhjdgsu87489YUFSfh483fhj==

07-26 13:55:47.174 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 12

07-26 13:55:47.174 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 0

07-26 13:55:51.293 com.myapp.xmpptest W/System.err: org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 5000ms (~5s). Used filter: No filter used or filter was ‘null’.

07-26 13:55:51.293 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 250)

07-26 13:55:51.293 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection.loginNonAnonymously(XMPPTCPConnect ion.java:374)

07-26 13:55:51.293 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :456)

07-26 13:55:51.293 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :414)

07-26 13:55:51.293 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection. java:863)

07-26 13:55:51.293 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.ja va:364)

07-26 13:55:51.293 com.myapp.xmpptest W/System.err: at com.myapp.xmpp.XmppService.connectAndAuthenticate(XmppService.java:492)

07-26 13:55:51.293 com.myapp.xmpptest W/System.err: at com.myapp.xmpp.XmppService$2.run(XmppService.java:195)

07-26 13:55:51.293 com.myapp.xmpptest W/System.err: at java.lang.Thread.run(Thread.java:818)

07-26 13:55:51.293 com.myapp.xmpptest I/XmppService: Before xmppConnection login…

07-26 13:55:51.293 com.myapp.xmpptest W/AbstractXMPPConnection: Connection closed with error

javax.net.ssl.SSLException: Read error: ssl=0x9abd4400: I/O error during system call, Connection timed out

at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)

at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketIm pl.java:753)

at java.io.InputStreamReader.read(InputStreamReader.java:231)

at java.io.BufferedReader.read(BufferedReader.java:325)

at org.jivesoftware.smack.util.ObservableReader.read(ObservableReader.java:41)

at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1515)

at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:992)

at org.kxml2.io.KXmlParser.next(KXmlParser.java:349)

at org.kxml2.io.KXmlParser.next(KXmlParser.java:313)

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1173)

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPCon nection.java:952)

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:967)

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

07-26 13:55:51.293 com.myapp.xmpptest D/xmppTest: XmppConnectionListener connectionClosedOnError()

07-26 13:55:51.293 com.myapp.xmpptest W/System.err: javax.net.ssl.SSLException: Read error: ssl=0x9abd4400: I/O error during system call, Connection timed out

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketIm pl.java:753)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at java.io.InputStreamReader.read(InputStreamReader.java:231)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at java.io.BufferedReader.read(BufferedReader.java:325)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.util.ObservableReader.read(ObservableReader.java:41)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1515)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:992)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.kxml2.io.KXmlParser.next(KXmlParser.java:349)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.kxml2.io.KXmlParser.next(KXmlParser.java:313)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1173)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPCon nection.java:952)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:967)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at java.lang.Thread.run(Thread.java:818)

07-26 13:55:51.303 com.myapp.xmpptest D/SMACK: XMPPConnection closed due to an exception (0)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: javax.net.ssl.SSLException: Read error: ssl=0x9abd4400: I/O error during system call, Connection timed out

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketIm pl.java:753)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at java.io.InputStreamReader.read(InputStreamReader.java:231)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at java.io.BufferedReader.read(BufferedReader.java:325)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.util.ObservableReader.read(ObservableReader.java:41)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1515)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:992)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.kxml2.io.KXmlParser.next(KXmlParser.java:349)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.kxml2.io.KXmlParser.next(KXmlParser.java:313)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1173)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPCon nection.java:952)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:967)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at java.lang.Thread.run(Thread.java:818)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: org.jivesoftware.smack.SmackException$NotConnectedException: Client is not, or no longer, connected.

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.throwNotConnectedExce ptionIfDoneAndResumptionNotPossible(XMPPTCPConnection.java:1248)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection.throwNotConnectedExceptionIfApprop riate(XMPPTCPConnection.java:345)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :451)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :414)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.ReconnectionManager$2.run(ReconnectionManager.java:248)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at java.lang.Thread.run(Thread.java:818)

07-26 13:55:51.303 com.myapp.xmpptest D/xmppTest: XmppConnectionListener reconnectionFailed()

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: org.jivesoftware.smack.SmackException$NotConnectedException: Client is not, or no longer, connected.

07-26 13:55:51.303 com.myapp.xmpptest D/SMACK: Reconnection failed due to an exception (0)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.throwNotConnectedExce ptionIfDoneAndResumptionNotPossible(XMPPTCPConnection.java:1248)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.SmackException$NotConnectedException: Client is not, or no longer, connected.

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.throwNotConnectedExce ptionIfDoneAndResumptionNotPossible(XMPPTCPConnection.java:1248)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection.throwNotConnectedExceptionIfApprop riate(XMPPTCPConnection.java:345)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :451)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :414)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.ReconnectionManager$2.run(ReconnectionManager.java:248)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at java.lang.Thread.run(Thread.java:818)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: org.jivesoftware.smack.tcp.XMPPTCPConnection.throwNotConnectedExceptionIfApprop riate(XMPPTCPConnection.java:345)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :451)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at com.myapp.xmpp.XmppService.connectAndAuthenticate(XmppService.java:538)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at com.myapp.xmpp.XmppService$2.run(XmppService.java:195)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at java.lang.Thread.run(Thread.java:818)

07-26 13:55:52.303 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 19

07-26 13:55:53.303 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 18

07-26 13:55:54.303 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 17

07-26 13:55:55.303 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 16

07-26 13:55:56.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 15

07-26 13:55:57.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 14

07-26 13:55:58.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 13

07-26 13:55:59.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 12

07-26 13:56:00.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 11

07-26 13:56:01.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 10

07-26 13:56:02.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 9

07-26 13:56:03.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 8

07-26 13:56:04.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 7

07-26 13:56:05.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 6

07-26 13:56:06.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 5

07-26 13:56:07.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 4

07-26 13:56:08.323 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 3

07-26 13:56:09.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 2

07-26 13:56:10.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 1

07-26 13:56:11.323 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 0

07-26 13:56:11.323 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 0

07-26 13:56:11.373 com.myapp.xmpptest D/SMACK: SENT (0): <stream:stream xmlns=‘jabber:client’ to=‘myapp.com’ xmlns:stream=‘http://etherx.jabber.org/streams’ version=‘1.0’ from=‘eaf60f002867230766bb74b4419dffca@myapp.com’ xml:lang=‘en’>

07-26 13:56:11.403 com.myapp.xmpptest D/SMACK: RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream=“http://etherx.jabber.org/streams” xmlns=“jabber:client” from=“myapp.com” id=“8dbb465e” xml:lang=“en” version=“1.0”>

07-26 13:56:11.433 com.myapp.xmpptest D/SMACK: RECV (0): stream:featuresPLAIN</mechanis ms></stream:features>

07-26 13:56:11.443 com.myapp.xmpptest D/SMACK: SENT (0):

07-26 13:56:11.473 com.myapp.xmpptest D/SMACK: RECV (0):

07-26 13:56:11.963 com.myapp.xmpptest D/SMACK: SENT (0): <stream:stream xmlns=‘jabber:client’ to=‘myapp.com’ xmlns:stream=‘http://etherx.jabber.org/streams’ version=‘1.0’ from=‘eaf60f002867230766bb74b4419dffca@myapp.com’ xml:lang=‘en’>

07-26 13:56:12.003 com.myapp.xmpptest D/SMACK: RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream=“http://etherx.jabber.org/streams” xmlns=“jabber:client” from=“myapp.com” id=“8dbb465e” xml:lang=“en” version=“1.0”>stream:featuresPLAIN</mechanis ms>zlib</stream:features>

07-26 13:56:12.003 com.myapp.xmpptest D/xmppTest: XmppConnectionListener connectionConnected()

07-26 13:56:12.003 com.myapp.xmpptest D/SMACK: XMPPConnection connected (0)

07-26 13:56:12.003 com.myapp.xmpptest D/SMACK: SENT (0): HJKSHGFJHJGKHDJHGJEHJKRHGJKFDHGhjshjkghruiehskrjgbjkeh5j4568o gjkfhdsgh589wwghjfdghsuHJKSHFIREHGHRUEIghgfhjdgsu87489YUFSfh483fhj==

07-26 13:56:12.223 com.myapp.xmpptest D/SMACK: RECV (0):

07-26 13:56:12.223 com.myapp.xmpptest D/SMACK: SENT (0): <stream:stream xmlns=‘jabber:client’ to=‘myapp.com’ xmlns:stream=‘http://etherx.jabber.org/streams’ version=‘1.0’ from=‘eaf60f002867230766bb74b4419dffca@myapp.com’ id=‘8dbb465e’ xml:lang=‘en’>

07-26 13:56:12.253 com.myapp.xmpptest D/SMACK: RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream=“http://etherx.jabber.org/streams” xmlns=“jabber:client” from=“myapp.com” id=“8dbb465e” xml:lang=“en” version=“1.0”>stream:featureszlib</stream:features>

07-26 13:56:12.253 com.myapp.xmpptest D/SMACK: SENT (0): d73d639de6435579< /bind>

07-26 13:56:12.283 com.myapp.xmpptest D/SMACK: RECV (0): eaf60f002867230766bb74b4419dffca@myapp.com/d73d639de6435579

07-26 13:56:12.293 com.myapp.xmpptest D/SMACK: SENT (0):

07-26 13:56:12.323 com.myapp.xmpptest D/SMACK: RECV (0):

07-26 13:56:12.323 com.myapp.xmpptest D/SMACK: User logged (0): eaf60f002867230766bb74b4419dffca@myapp.com:5222/d73d639de6435579

07-26 13:56:12.323 com.myapp.xmpptest D/xmppTest: XmppConnectionListener authenticated(). resumed : false

07-26 13:56:12.323 com.myapp.xmpptest D/xmppTest: joining control room

07-26 13:56:12.323 com.myapp.xmpptest D/SMACK: XMPPConnection authenticated (0)

07-26 13:56:12.323 com.myapp.xmpptest D/xmppTest: XmppConnectionListener reconnectionSuccessful()

07-26 13:56:12.323 com.myapp.xmpptest D/SMACK: SENT (0):

07-26 13:56:12.323 com.myapp.xmpptest D/SMACK: SENT (0):

If I understand correctly from the logs, I get the exception when I try to reconnect immediately in network change event when the device connects to the internet from airplane mode. However it does eventually connect via reconnection manager. The code that I am using to trigger xmpp connect and login is as follows:

// The network monitor

private BroadcastReceiver networkMonitor = new BroadcastReceiver() {

@Override

public void onReceive(Context context, Intent intent) {

if (isOnline && !Utilities.isOnline(AbstractActivity.this)) {

isOnline = false;

} else if (!isOnline && Utilities.isOnline(AbstractActivity.this)) {

// Trigger only when going from offline to online

isOnline = Utilities.isOnline(AbstractActivity.this);

// Re-establish the xmpp connection if it was disconnected

if (isOnline ) {

connectAndAuthenticate();

}

}

}

};

public void connectAndAuthenticate() {

if(xmppConnection==null){

XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder()

.setUsernameAndPassword(hashedUserName, getPassword())

.setServiceName(serviceName)

.setHost(getCoreServer())

.setSendPresence(true)

.setSecurityMode(ConnectionConfiguration.SecurityMode.required)

.setPort(Integer.parseInt(port))

.setResource(getDeviceID());

if (BuildConfig.DEBUG) {

builder.setDebuggerEnabled(true);

}

XMPPTCPConnectionConfiguration config = builder.build();

xmppConnection = new MVXMPPTCPConnection(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);

}

// connect

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();

}

// login

try {

Log.i(TAG, “Before xmppConnection login…”);

xmppConnection.login(hashedUserName, getPassword(), getDeviceID());

Log.i(TAG, “After xmppConnection login…”);

// return

} catch (SmackException.AlreadyLoggedInException e) {

e.printStackTrace();

} catch (SmackException.ConnectionException e) {

e.printStackTrace();

} catch (XMPPException e) {

e.printStackTrace();

} catch (Exception e) {

e.printStackTrace();

}

}

Let me know if you need any more details.

Thanks.

Has anyone found the reason why this is happening? When I looked at the open fire logs, I see a SSL Handshake failure errors. The logs from open fire are as follows

2016.08.24 07:24:30** **org.jivesoftware.openfire.nio.ConnectionHandler - ConnectionHandler reports IOException for session: (SOCKET, R: /70.198.72.125:5004, L: /172.16.23.40:5222, S: 0.0.0.0/0.0.0.0:5222)

javax.net.ssl.SSLHandshakeException: SSL handshake failed.

at org.apache.mina.filter.SSLFilter.messageReceived(SSLFilter.java:416)

at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)

at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilt erChain.java:53)

at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceive d(AbstractIoFilterChain.java:648)

at org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.messageReceived (AbstractIoFilterChain.java:499)

at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)

at org.apache.mina.common.support.AbstractIoFilterChain.fireMessageReceived(Abstra ctIoFilterChain.java:293)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.read(SocketIoProcessor.j ava:228)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.process(SocketIoProcesso r.java:198)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.access$400(SocketIoProce ssor.java:45)

at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProce ssor.java:485)

at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

at sun.security.ssl.EngineInputRecord.bytesInCompletePacket(Unknown Source)

at sun.security.ssl.SSLEngineImpl.readNetRecord(Unknown Source)

at sun.security.ssl.SSLEngineImpl.unwrap(Unknown Source)

at javax.net.ssl.SSLEngine.unwrap(Unknown Source)

at org.apache.mina.filter.support.SSLHandler.unwrap0(SSLHandler.java:668)

at org.apache.mina.filter.support.SSLHandler.unwrapHandshake(SSLHandler.java:624)

at org.apache.mina.filter.support.SSLHandler.handshake(SSLHandler.java:503)

at org.apache.mina.filter.support.SSLHandler.messageReceived(SSLHandler.java:306)

at org.apache.mina.filter.SSLFilter.messageReceived(SSLFilter.java:392)

… 14 more

2016.08.24 07:24:56** **org.jivesoftware.openfire.nio.ConnectionHandler - ConnectionHandler reports IOException for session: (SOCKET, R: /70.198.72.125:5016, L: /172.16.23.40:5222, S: 0.0.0.0/0.0.0.0:5222)

javax.net.ssl.SSLHandshakeException: SSL handshake failed.

at org.apache.mina.filter.SSLFilter.messageReceived(SSLFilter.java:416)

at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)

at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilt erChain.java:53)

at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceive d(AbstractIoFilterChain.java:648)

at org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.messageReceived (AbstractIoFilterChain.java:499)

at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)

at org.apache.mina.common.support.AbstractIoFilterChain.fireMessageReceived(Abstra ctIoFilterChain.java:293)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.read(SocketIoProcessor.j ava:228)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.process(SocketIoProcesso r.java:198)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.access$400(SocketIoProce ssor.java:45)

at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProce ssor.java:485)

at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

Caused by: javax.net.ssl.SSLException: Unsupported record version Unknown-97.117

at sun.security.ssl.InputRecord.checkRecordVersion(Unknown Source)

at sun.security.ssl.EngineInputRecord.bytesInCompletePacket(Unknown Source)

at sun.security.ssl.SSLEngineImpl.readNetRecord(Unknown Source)

at sun.security.ssl.SSLEngineImpl.unwrap(Unknown Source)

at javax.net.ssl.SSLEngine.unwrap(Unknown Source)

at org.apache.mina.filter.support.SSLHandler.unwrap0(SSLHandler.java:668)

at org.apache.mina.filter.support.SSLHandler.unwrapHandshake(SSLHandler.java:624)

at org.apache.mina.filter.support.SSLHandler.handshake(SSLHandler.java:503)

at org.apache.mina.filter.support.SSLHandler.messageReceived(SSLHandler.java:306)

at org.apache.mina.filter.SSLFilter.messageReceived(SSLFilter.java:392)

… 14 more

Has this anything to do with the version upgrade from SSL v2/v3 to TLS? I would really appreciate any response as I am kind of stuck here.

Thanks.