jitsi / jitsi-android

Jitsi for Android is an Android port of the Jitsi project: The most feature-rich communicator with support for encrypted audio/video, chat and presence over SIP and XMPP
Apache License 2.0
415 stars 258 forks source link

XMPP account never gets online #7

Open jitsi-jenkins opened 9 years ago

jitsi-jenkins commented 9 years ago

Sometimes XMPP account once became offline never reconnects again. In this situation when user tries to disable the account the app will freeze on "Disconnecting account" progress dialog. Investigation shows that "disconnect" thread is waiting on "initializationLock" of Jabber provider. At the same time another thread(Keep alive thread) owns the same lock and tries to unregister the account. But it never does as it's blocked on another monitor in close() method of BufferedReader. Since "initializationLock" is never realesed we have a deadlock. The reason why close() method is blocked is unknown for now.

(Issue migrated from https://trac.jitsi.org/ticket/1266)

jitsi-jenkins commented 9 years ago

The situation from description above was also caused by "enter password" dialog being hidden by the contactlist on startup. Dialog was waiting forever thus blocking login thread and not allowing to disconnect. Fixed in https://github.com/jitsi/jitsi-android/commit/89e6c44dc6d63ec8abb807f73af7770dff7f2635.

jitsi-jenkins commented 9 years ago

Sometimes Smack gets blocked on Socket connect() for even a minute, because it's called without specified timeout. This will also block "Disconnecting account" dialog on accounts list screen for the same amount of time.

java.lang.Thread.State: RUNNABLE
      at libcore.io.Posix.connect(Posix.java:-1)
      at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:85)
      at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
      at libcore.io.IoBridge.connect(IoBridge.java:112)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
      at java.net.Socket.connect(Socket.java:842)
      at java.net.Socket.connect(Socket.java:785)
      at org.jivesoftware.smack.proxy.DirectSocketFactory.createSocket(DirectSocketFactory.java:28)
      at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:527)
      at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:976)
      at net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabberImpl.connectAndLogin(ProtocolProviderServiceJabberImpl.java:1172)
      at net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabberImpl.connectAndLogin(ProtocolProviderServiceJabberImpl.java:946)
      at net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabberImpl.connectUsingSRVRecords(ProtocolProviderServiceJabberImpl.java:885)
      at net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabberImpl.initializeConnectAndLogin(ProtocolProviderServiceJabberImpl.java:678)
      at net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabberImpl.register(ProtocolProviderServiceJabberImpl.java:475)
      at net.java.sip.communicator.util.account.LoginManager$RegisterProvider.run(LoginManager.java:426)