AnsweredAssumed Answered

Smack 4.2.0-rc2 ReconnectionManager does not return its status to ConnectionListener

Question asked by cmeng on Jan 13, 2017
Latest reply on Jan 13, 2017 by cmeng

aTalk has JabberConnectionListener() class implementation for smack ConnectionLister, it is also configured to use Smack 4.2.0-rc2 ReconnectionManager. During account login process, the JabberConnectionListener is registered with the XMPPTCPConnection just prior to making actual xmpp connect().

 

/* Start monitoring the status before connection-login. Only register listener once */
mConnection = new XMPPTCPConnection(config.build());

if (connectionListener == null) {
   connectionListener = new JabberConnectionListener();
   mConnection.addConnectionListener(connectionListener);
}

 

Upon successfully network connection, JabberConnectionListener#connected() method then proceeds to register ConnectionManager using mConnection.

JabberConnectionListener()#connected(XMPPConnection connection)

{

...

======= following two statements are actually called via sub-routine, hence it uses mConnection instead of connection ===========

ReconnectionManager reconnectionManager = ReconnectionManager.getInstanceFor(mConnection);
reconnectionManager.enableAutomaticReconnection();

...

}

 

All the callback methods of the JabberConnectionListener are working as expected in the whole login in process until authenticated => network lost.

When I simulated a network lost, the connectionClosedOnError(Exception exception)

is also get triggered as shown in bold in the log file, and the ReconnectionManager reconnect attempt is also working correctly as seen from the log file.

 

When the network is again resumed, the ReconnectionManager does make a successful re-connection to the network and resume with the server. However the problem is, all the status of the ReconnectionManager in the reconnection process are not reported back to the JabberConnectionListener() and the application is unaware on successful server re-connect. When the application get triggered by other event, it founds that it is still in the unregistration state when the network is lost, so it sends an presence-unavailable to the server.

 

Is there something I have left out, that causes the JabberConnectionListener() not being informed of the ReconnectionManager reconnection status.

I checked through the ConnectionManager source, but cannot see a way I can register JabberConnectionListener with the ReconnectionManager.

 

 

=================== Smack log with simulatate network lost and resume

01-13 14:59:45.527 org.atalk.android W/αTalk: [6] org.jivesoftware.smack.AbstractXMPPConnection.callConnectionClosedOnErrorListen er() Connection XMPPTCPConnection[leopard@atalk.org/atalk] (0) closed with error

                                              javax.net.ssl.SSLException: Read error: ssl=0xaee21600: 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:728)

                                                  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:1227)

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

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

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

01-13 14:59:45.537 org.atalk.android E/αTalk: [6] impl.protocol.jabber.ProtocolProviderServiceJabberImpl.connectionClosedOnError( ).1286 connection Closed OnError: Read error: ssl=0xaee21600: I/O error during system call, Connection timed out

                                              javax.net.ssl.SSLException: Read error: ssl=0xaee21600: 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:728)

                                                  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:1227)

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

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

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

01-13 14:59:45.667 org.atalk.android D/SMACK: XMPPConnection closed (XMPPTCPConnection[leopard@atalk.org/atalk] (0))

01-13 14:59:45.667 org.atalk.android D/SMACK: XMPPConnection closed due to an exception (XMPPTCPConnection[leopard@atalk.org/atalk] (0))

                                              javax.net.ssl.SSLException: Read error: ssl=0xaee21600: 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:728)

                                                  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:1227)

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

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

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

01-13 14:59:46.357 org.atalk.android I/αTalk: [1] impl.sysactivity.SystemActivityNotificationsServiceImpl.fireSystemActivityEvent ().489 Received system activity event: net.java.sip.communicator.service.sysactivity.event.SystemActivityEvent[eventID =9]

01-13 14:59:46.677 org.atalk.android D/SMACK: XMPPConnection (XMPPTCPConnection[leopard@atalk.org/atalk] (0)) will reconnect in 3

01-13 14:59:47.677 org.atalk.android D/SMACK: XMPPConnection (XMPPTCPConnection[leopard@atalk.org/atalk] (0)) will reconnect in 2

01-13 14:59:48.677 org.atalk.android D/SMACK: XMPPConnection (XMPPTCPConnection[leopard@atalk.org/atalk] (0)) will reconnect in 1

01-13 14:59:49.677 org.atalk.android D/SMACK: XMPPConnection (XMPPTCPConnection[leopard@atalk.org/atalk] (0)) will reconnect in 0

01-13 14:59:49.677 org.atalk.android D/SMACK: XMPPConnection (XMPPTCPConnection[leopard@atalk.org/atalk] (0)) will reconnect in 0

01-13 14:59:54.977 org.atalk.android D/SMACK: Reconnection failed due to an exception (XMPPTCPConnection[leopard@atalk.org/atalk] (0))

                                              org.jivesoftware.smack.SmackException$ConnectionException: The following addresses failed: 'atalk.sytes.net:5222' failed because: de.measite.minidns.util.MultipleIoException: sendto failed: ENETUNREACH (Network is unreachable), failed to connect to /192.168.1.254 (port 53) after 5000ms: connect failed:

.....

01-13 15:00:33.327 org.atalk.android D/SMACK: XMPPConnection (XMPPTCPConnection[leopard@atalk.org/atalk] (0)) will reconnect in 3

01-13 15:00:34.327 org.atalk.android D/SMACK: XMPPConnection (XMPPTCPConnection[leopard@atalk.org/atalk] (0)) will reconnect in 2

01-13 15:00:35.337 org.atalk.android D/SMACK: XMPPConnection (XMPPTCPConnection[leopard@atalk.org/atalk] (0)) will reconnect in 1

01-13 15:00:36.337 org.atalk.android D/SMACK: XMPPConnection (XMPPTCPConnection[leopard@atalk.org/atalk] (0)) will reconnect in 0

01-13 15:00:36.337 org.atalk.android D/SMACK: XMPPConnection (XMPPTCPConnection[leopard@atalk.org/atalk] (0)) will reconnect in 0

01-13 15:00:38.107 org.atalk.android I/αTalk: [1] impl.sysactivity.SystemActivityNotificationsServiceImpl.fireSystemActivityEvent ().489 Received system activity event: net.java.sip.communicator.service.sysactivity.event.SystemActivityEvent[eventID =9]

01-13 15:00:42.087 org.atalk.android D/SMACK: SENT (0): <stream:stream xmlns='jabber:client' to='atalk.org' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>

01-13 15:00:42.087 org.atalk.android D/SMACK: RECV (0): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='16282940281844612208' from='atalk.org' version='1.0' xml:lang='en'><stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='xPSMVlLIKeByCDbCp8QJ1d0gn9Q='/><register xmlns='http://jabber.org/features/iq-register'/><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>SCRAM-SHA-1</mechanism><mec hanism>PLAIN</mechanism><mechanism>X-OAUTH2</mechanism></mechanisms></stream:fea tures>

01-13 15:00:42.087 org.atalk.android D/SMACK: SENT (0): <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'></starttls>

01-13 15:00:42.107 org.atalk.android D/SMACK: RECV (0): <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>

01-13 15:00:42.137 org.atalk.android D/SMACK: SENT (0): <stream:stream xmlns='jabber:client' to='atalk.org' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>

01-13 15:00:42.147 org.atalk.android D/SMACK: RECV (0): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='18227248040208343624' from='atalk.org' version='1.0' xml:lang='en'>

01-13 15:00:42.147 org.atalk.android D/SMACK: RECV (0): <stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='xPSMVlLIKeByCDbCp8QJ1d0gn9Q='/><register xmlns='http://jabber.org/features/iq-register'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>SCRAM-SHA-1</mechanism><mec hanism>PLAIN</mechanism><mechanism>X-OAUTH2</mechanism></mechanisms></stream:fea tures>

01-13 15:00:42.147 org.atalk.android D/SMACK: XMPPConnection connected (XMPPTCPConnection[leopard@atalk.org/atalk] (0))

01-13 15:00:42.147 org.atalk.android D/SMACK: SENT (0): <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='SCRAM-SHA-1'>biwsbj1sZW9wYXJkLHI9eSlaZnoqRUY6XTc4d0FUdGd4QU1DVHQwTWc 6WmJRa1s=</auth>

01-13 15:00:42.207 org.atalk.android D/SMACK: RECV (0): <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>cj15KVpmeipFRjpdNzh3QVR0Z3hBTUNUdDBNZz paYlFrW0JqdlVldmc3YTExY1JRc0tpeGhXZmc9PSxzPUNxQmkvM2h5a2JWckRFcnd6RlNJTGc9PSxpPT QwOTY=</challenge>

01-13 15:00:42.207 org.atalk.android D/SMACK: SENT (0): <response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>Yz1iaXdzLHI9eSlaZnoqRUY6XTc4d0FUdGd4QU 1DVHQwTWc6WmJRa1tCanZVZXZnN2ExMWNSUXNLaXhoV2ZnPT0scD14U1Bkbjl5bVdqVytyaTJhbTJTRU R5bUlJVk09</response>

01-13 15:00:42.217 org.atalk.android D/SMACK: RECV (0): <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>dj1oRFpvWDlSTTdlaXNOVnAybjNLYlFSV0pxdX M9</success>

01-13 15:00:42.217 org.atalk.android D/SMACK: SENT (0): <stream:stream xmlns='jabber:client' to='atalk.org' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' id='18227248040208343624' xml:lang='en'><resume xmlns='urn:xmpp:sm:3' h='10' previd='g2gCbQAAAAVhdGFsa2gDYgAABcxiAARvlGIAAByJ'/>

01-13 15:00:42.407 org.atalk.android D/SMACK: RECV (0): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='12510061377263721146' from='atalk.org' version='1.0' xml:lang='en'>

01-13 15:00:42.407 org.atalk.android D/SMACK: RECV (0): <stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='xPSMVlLIKeByCDbCp8QJ1d0gn9Q='/><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/><session xmlns='urn:ietf:params:xml:ns:xmpp-session'><optional/></session><ver xmlns='urn:xmpp:features:rosterver'/><sm xmlns='urn:xmpp:sm:2'/><sm xmlns='urn:xmpp:sm:3'/><csi xmlns='urn:xmpp:csi:0'/></stream:features>

01-13 15:00:42.407 org.atalk.android D/SMACK: RECV (0): <resumed xmlns='urn:xmpp:sm:3' h='9' previd='g2gCbQAAAAVhdGFsa2gDYgAABcxiAARvlGIAAByJ'/>

01-13 15:00:42.407 org.atalk.android D/SMACK: User logged (0): leopard@atalk.org:5222/atalk

01-13 15:00:42.407 org.atalk.android D/SMACK: XMPPConnection authenticated (XMPPTCPConnection[leopard@atalk.org/atalk] (0)) and resumed

01-13 15:00:42.407 org.atalk.android D/SMACK: RECV (0): <r xmlns='urn:xmpp:sm:3'/>

01-13 15:00:42.407 org.atalk.android D/SMACK: SENT (0): <presence id='uth8t-73' type='unavailable'><x xmlns='vcard-temp:x:update'><photo>ed341d7cb4d39f423989c0cf5fe8d9527be3ffde</photo></x></presence><r xmlns='urn:xmpp:sm:3'/><r xmlns='urn:xmpp:sm:3'/><a xmlns='urn:xmpp:sm:3' h='10'/>

01-13 15:00:42.417 org.atalk.android W/αTalk: [7] org.jivesoftware.smack.roster.Roster.processStanza() Roster not loaded while processing Presence Stanza [from=abc123@atalk.org/jitsi-1f93jo1,id=uth8t-75,type=unavailable,]

01-13 15:00:42.747 org.atalk.android D/SMACK: RECV (0): <a xmlns='urn:xmpp:sm:3' h='10'/>

01-13 15:00:42.747 org.atalk.android D/SMACK: RECV (0): <a xmlns='urn:xmpp:sm:3' h='10'/>

01-13 15:01:48.387 org.atalk.android I/αTalk: [1] org.atalk.android.aTalkApp.setCurrentActivity().326 Current activity set to null

01-13 15:01:48.977 org.atalk.android V/ActivityThread: updateVisibility : ActivityRecord{c48ca94 token=android.os.BinderProxy@30b22dc5 {org.atalk.android/org.atalk.android.gui.aTalk}} show : false

01-13 15:03:38.567 org.atalk.android W/art: Suspending all threads took: 7.981ms

01-13 15:04:42.657 org.atalk.android D/SMACK: RECV (0): <iq from='atalk.org' to='leopard@atalk.org/atalk' id='11890851664719599559' type='get'><ping xmlns='urn:xmpp:ping'/></iq>

01-13 15:04:42.657 org.atalk.android D/SMACK: RECV (0): <r xmlns='urn:xmpp:sm:3'/>

01-13 15:04:42.657 org.atalk.android D/SMACK: SENT (0): <a xmlns='urn:xmpp:sm:3' h='11'/>

01-13 15:04:42.697 org.atalk.android D/SMACK: SENT (0): <iq to='atalk.org' id='11890851664719599559' type='result'></iq>

Outcomes