powered by Jive Software

Smack 4.2.3-SNAPSHOT: aTalk gets disconnected from server due to unexpected exception while in standby

android

#1

With aTalk installed on android device. While replying ping from server in standby, aTalk unexpectedly gets disconnected from network by callConnectionClosedOnErrorListener Exception. It is 100% repeatable on Note-2 and occasionally on Note-3. The callConnectionClosedOnErrorListener may at times also happen on Note-2 and Note-3 while doing testing.

Once it happens on Note-2 while device is in standby, all re connection attempts by ReconnectionManager will always failed until the device is waked up by user. Then the next connection is always successfully.

When failure occurred, external ping to the android device is also not successful. Any option within smack to disabled device from network disconnection?

============ aTalk log ===============

02-02 11:18:18.166 D/SMACK: RECV (0): <iq to='kingfisher@atalk.org/atalk' from='atalk.org' type='get' id='4900234946809486684'><ping xmlns='urn:xmpp:ping'/></iq>
02-02 11:18:18.171 D/SMACK: SENT (0): <iq to='atalk.org' id='4900234946809486684' type='result'></iq>
02-02 11:22:18.196 D/SMACK: RECV (0): <iq to='kingfisher@atalk.org/atalk' from='atalk.org' type='get' id='1353268458384189151'><ping xmlns='urn:xmpp:ping'/></iq>
02-02 11:22:18.201 D/SMACK: SENT (0): <iq to='atalk.org' id='1353268458384189151' type='result'></iq>
02-02 11:22:18.946 W/aTalk: [35] org.jivesoftware.smack.AbstractXMPPConnection.callConnectionClosedOnErrorListener() Connection XMPPTCPConnection[kingfisher@atalk.org/atalk] (0) closed with error
                            javax.net.ssl.SSLException: Read error: ssl=0x5b557d10: I/O error during system call, Connection timed out
                                at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_read(Native Method)
                                at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:686)
                                at java.io.InputStreamReader.read(InputStreamReader.java:244)
                                at java.io.BufferedReader.read(BufferedReader.java:310)
                                at org.jivesoftware.smack.util.ObservableReader.read(ObservableReader.java:42)
                                at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1496)
                                at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:979)
                                at org.kxml2.io.KXmlParser.next(KXmlParser.java:346)
                                at org.kxml2.io.KXmlParser.next(KXmlParser.java:310)
                                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1244)
                                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:994)
                                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:1010)
                                at java.lang.Thread.run(Thread.java:841)
02-02 11:22:19.011 D/SMACK: XMPPConnection closed due to an exception (XMPPTCPConnection[kingfisher@atalk.org/atalk] (0))
                            javax.net.ssl.SSLException: Read error: ssl=0x5b557d10: I/O error during system call, Connection timed out
                                at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_read(Native Method)
                                at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:686)
                                at java.io.InputStreamReader.read(InputStreamReader.java:244)
                                at java.io.BufferedReader.read(BufferedReader.java:310)
                                at org.jivesoftware.smack.util.ObservableReader.read(ObservableReader.java:42)
                                at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1496)
                                at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:979)
                                at org.kxml2.io.KXmlParser.next(KXmlParser.java:346)
                                at org.kxml2.io.KXmlParser.next(KXmlParser.java:310)
                                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1244)
                                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:994)
                                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:1010)
                                at java.lang.Thread.run(Thread.java:841)
02-02 11:22:19.591 I/aTalk: [1] impl.sysactivity.SystemActivityNotificationsServiceImpl.fireSystemActivityEvent().487 Received system activity event: net.java.sip.communicator.service.sysactivity.event.SystemActivityEvent[eventID=9]
02-02 11:22:20.011 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk] (0)) will reconnect in 12
02-02 11:22:21.011 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk] (0)) will reconnect in 11
02-02 11:22:22.011 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk] (0)) will reconnect in 10
02-02 11:22:23.011 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk] (0)) will reconnect in 9
02-02 11:22:24.011 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk] (0)) will reconnect in 8
02-02 11:22:25.011 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk] (0)) will reconnect in 7
02-02 11:22:26.016 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk] (0)) will reconnect in 6
02-02 11:22:27.016 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk] (0)) will reconnect in 5
02-02 11:22:28.021 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk] (0)) will reconnect in 4
02-02 11:22:29.021 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk] (0)) will reconnect in 3
02-02 11:22:30.016 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk] (0)) will reconnect in 2
02-02 11:22:31.021 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk] (0)) will reconnect in 1
02-02 11:22:32.021 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk] (0)) will reconnect in 0
02-02 11:22:32.021 I/aTalk: [36] impl.protocol.jabber.ProtocolProviderServiceJabberImpl.reconnectingIn().1404 ReconnectionManager starting connection attempt...
02-02 11:22:32.021 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk] (0)) will reconnect in 0
02-02 11:22:32.026 I/aTalk: [36] impl.protocol.jabber.ProtocolProviderServiceJabberImpl.reconnectingIn().1404 ReconnectionManager starting connection attempt...
02-02 11:22:32.086 D/SMACK: Reconnection failed due to an exception (XMPPTCPConnection[kingfisher@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: ENETUNREACH (Network is unreachable), sendto failed: ENETUNREACH (Network is unreachable), failed to connect to /8.8.8.8 (port 53) after 5000ms: connect failed: ENETUNREACH (Network is unreachable), sendto failed: ENETUNREACH (Network is unreachable), failed to connect to /2001:4860:4860::8888 (port 53) after 5000ms: connect failed: ENETUNREACH (Network is unreachable), sendto failed: ENETUNREACH (Network is unreachable), failed to connect to m.root-servers.net/202.12.27.33 (port 53) after 5000ms: connect failed: ENETUNREACH (Network is unreachable), sendto failed: ENETUNREACH (Network is unreachable), failed to connect to d.root-servers.net/2001:500:2d::d (port 53) after 5000ms: connect failed: ENETUNREACH (Network is unreachable)
                                at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPConnection.java:619)
                                at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection.java:902)
                                at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.java:380)
                                at org.jivesoftware.smack.ReconnectionManager$2.run(ReconnectionManager.java:289)
                                at java.lang.Thread.run(Thread.java:841)

###  The whole cycle repeated until device waked up by user ###

#2

Closed the issue, may be this is not a smack problem.


#3

I can imagine this could have to do with android wakelocks/energy saving modes/android doze…


#4

Yep, you usually want to whitelist your Smack app from battery optimizations.


#5

Actually is that the WiFi is allowed to turn off when device go to standby. Just has to set to never. The only problem s that the reconnectManager keeps trying throughout the night until user wakes up the device, draining battery.


#6

So it would be a good idea for smack-android to detect, whether the device has an active internet connection?


#7

You shouldn’t use ReconnectionManager on Android.


#8

Actually the smack ReconnectionManager is working very well on android, which I have used to replace the old jitsi reconnectionManager long time ago.

The observed problem is not a problem of ReconnectionManager, but actually due to user action to disable wifi when device goes into standby; and the Note-2 that I used for testing does not equip with a SIM card, hence no network connection when Wifi is off.

I am thinking may be it is good idea to issue an alert dialog upon detecting user disabled wifi on standby and there is no network SIM installed on the device; possibly also stops reconnectionManager. Under this case.User has to manually make the re-connection on device wake up.

Personally I was also caught unaware that the wifi is disabled on standby, and keep looking for cause why atalk attempts to connect always failed over night. The alert should help.


#9

But creates additional unecessary load on the network interface as Smack’s ReconnectionManager is not aware about the connectivity of the device. I recomment a custom reconnection logic based on PingManagerWithAlarmManager and NETWORK_CONNECTIVITY_CHANGED listeners, and of course, connectionClosedOnException listeners.


#10

Thanks for the input. I will look at it once has more time.

While testing message carbons on 3 devices, Note-3 suddenly disconnects itself unexpectedly while WiFI is set to always connected. Not sure how many trials did smack attempted before throwing callConnectionClosedOnErrorListener.

02-03 16:46:34.005 D/SMACK: SENT (0): <message to='swordfish@atalk.org/atalk' id='1517647594011834918743' type='chat'><body>carbons testing</body><thread>3OilD0</thread><active xmlns='http://jabber.org/protocol/chatstates'/></message>
02-03 16:46:34.005 D/SMACK: SENT (0): <r xmlns='urn:xmpp:sm:3'/>
02-03 16:47:49.985 W/aTalk: [18] org.jivesoftware.smack.AbstractXMPPConnection.callConnectionClosedOnErrorListener() Connection XMPPTCPConnection[kingfisher@atalk.org/atalk2] (0) closed with error
                            javax.net.ssl.SSLException: Read error: ssl=0xafa59200: I/O error during system call, Connection reset by peer
                                at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
                                at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.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:42)
                                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(XMPPTCPConnection.java:1244)
                                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:994)
                                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:1010)
                                at java.lang.Thread.run(Thread.java:818)
02-03 16:47:50.015 D/SMACK: XMPPConnection closed due to an exception (XMPPTCPConnection[kingfisher@atalk.org/atalk2] (0))
                            javax.net.ssl.SSLException: Read error: ssl=0xafa59200: I/O error during system call, Connection reset by peer
                                at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
                                at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.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:42)
                                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(XMPPTCPConnection.java:1244)
                                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:994)
                                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:1010)
                                at java.lang.Thread.run(Thread.java:818)
02-03 16:47:51.045 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk2] (0)) will reconnect in 9
02-03 16:47:52.045 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk2] (0)) will reconnect in 8
02-03 16:47:53.055 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk2] (0)) will reconnect in 7
02-03 16:47:54.055 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk2] (0)) will reconnect in 6
02-03 16:47:55.055 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk2] (0)) will reconnect in 5
02-03 16:47:56.055 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk2] (0)) will reconnect in 4
02-03 16:47:57.055 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk2] (0)) will reconnect in 3
02-03 16:47:57.805 E/aTalk: [2] org.atalk.android.gui.chat.ChatPanel.log() null
02-03 16:47:57.805 W/aTalk: [2] org.atalk.android.gui.chat.ChatController.log() Send message failed: The provider must be signed on the Jabber service before being able to communicate.
02-03 16:47:58.055 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk2] (0)) will reconnect in 2
02-03 16:47:59.055 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk2] (0)) will reconnect in 1
02-03 16:48:00.055 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk2] (0)) will reconnect in 0
02-03 16:48:00.055 I/aTalk: [19] impl.protocol.jabber.ProtocolProviderServiceJabberImpl.reconnectingIn().1403 ReconnectionManager starting connection attempt...
02-03 16:48:00.055 D/SMACK: XMPPConnection (XMPPTCPConnection[kingfisher@atalk.org/atalk2] (0)) will reconnect in 0
02-03 16:48:00.055 I/aTalk: [19] impl.protocol.jabber.ProtocolProviderServiceJabberImpl.reconnectingIn().1403 ReconnectionManager starting connection attempt...
02-03 16:48:00.695 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'>
02-03 16:48:00.705 D/SMACK: RECV (0): <?xml version='1.0'?><stream:stream id='15574333399842442368' version='1.0' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' from='atalk.org' xmlns='jabber:client'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>X-OAUTH2</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
02-03 16:48:00.705 D/SMACK: SENT (0): <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'></starttls>
02-03 16:48:00.705 D/SMACK: RECV (0): <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
02-03 16:48:00.805 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'>
02-03 16:48:00.805 D/SMACK: RECV (0): <?xml version='1.0'?><stream:stream id='11763962133191896175' version='1.0' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' from='atalk.org' xmlns='jabber:client'>
02-03 16:48:00.805 D/SMACK: RECV (0): <stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>X-OAUTH2</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms><register xmlns='http://jabber.org/features/iq-register'/></stream:features>