I am developing a chat app in Android which runs in all versions of Android ( starting from 2.3.5 to the latest kitkat) and every thing is working fine when it comes to chatting, but I am facing one BIG issue.
The issue is when I generate the apk and install the apk in Android mobile (using package installer), the user goes offline in some time ( say in XYZ mins ).In S3 it is 40 mins and in S5 it is 30 mins and in htc desire hd it is 20 mins after which the user is disconnected.
But when I install the same app using Eclipse to an android phone, the user is online ( as I am checking the status of the XMPP connection every 5 seconds and reconnecting if there is a disconnect to the ejabberd server even after 1 day which is as expected)
I am terribly confused as whether I am doing something wrong when I generate apk from the Android project. But not to my knowledge.
If anyone can shed some light on this blocker issue I will be really greatful.
I am using asmack library and the version is asmack-android-8-4.0.4
Honestly I am not finding any issue with the ejabbered server nor with the ejabberd server.
Any pointers to solve the issue will be greatly appreciated. Please let me know if you need any additional info.
To summarize its the installation mode which is giving me issues.
Library version which we are using is asmack-android-8-4.0.4.jar
Debug Apk(Application installed from Eclipse) is not having any issue, while Release Apk(Application exported without using ProGurard) has re-connect issue.
User goes offline in some time, and is never able to come back online again.
We are testing this on Wifi connection, and we are completely agree that this can happen when device go in sleep mode due to inactivity for longer time. But, after waking the device up (which we believe sends CONNECTIVITY_CHANGE system action) due to some reason subsequent attempts to re-connect fails in Release APK
Our Connection Mechanism is like this
Android Service has Separate worker Thread, which is responsible for maintaining persistent connection. PingManager has registered PingFailedListener, and it is wokring perfectly with appropriate ping interval. in OnPIngFailed we are disconnection connection XmppConnection.disconnect, and reconnecting again . This mechanism works without any issue in Debug APK
Note : security mode is disabled, ==>SecurityMode.disabled We have gone through this README guideline. https://github.com/Flowdalic/asmack/blob/master/README.asmack
We are not using ProGuard,
project.properties is not pointing to any "proguard-android-optimize.txt" and "proguard-project.txt" has everything commented out, to be on safer side we have added keep class so that important Smack classes are not optimized away. I have attached project.properties for reference. I have attached proguard-project.txt for reference.