As stated in the subject line, my Cordova app running on Android is experiencing issues with connecting to CB lite after the app has been put in background mode for a number of hours. This is happening to all of my Android users and me.
When I look at the network log of the traffic of the app after resumption, all CB lite calls are pending.
I need urgent help on this as it’s killing user adoption on Android. I’m not experiencing this issue on IOS.
Is there a inactivity timeout setting I can adjust?
To all the Cordova developers for Android, does anyone have success with their app running in the background and reconnecting to CB lite on resumption?
Is the background mode getting triggered in code or when the user leaves the app?
cblite.getURL() is usually called when the app is initialized to retrieve the listener URL. Where did you call cblite.getURL() after the app got backgrounded?
With regards to the pending mode for the API calls, do you see the pending state in the Chrome debugger console?
Let me clarify “user leaves the app”, the app is background mode and is paused. If the app is shutdown and restarted, everything with CBL is fine. But there’s no way through code to do a full shutdown and restart with Cordova.
I have one request to verity.
From your comment, once the app resumed, the app can obtain URL of CBL REST API endpoint. Can you try to access its URL from Android browser or to access from out-side of Android device/emulator by browser or curl command?
If Http server can response, JavaScript or WebView which is used by Cordova/PhoneGap has issue.
If Http server can NOT response, Couchbase Lite Java Listener has issue or enter bad state.
But when trying to connect to the app database, the API call stays in “pending” mode, no response.
Could you please share the details of “pending” mode? If you wait for a while, do you receive timeout or some error response?
We’d like to reproduce this issue, could you please provide CBL for PhoneGap version?
I’m pretty sure that the WebView is not the issue. On resume, cblite.getURL(function (error, url) is working. But if I make a REST call to my database, the calls are pending.
I’m going to modify my to make a call to sync gateway on resume. If it responds and the REST call to the local db doesn’t, we’ll know that the WebView is not the culprit.
I’ll let you know in 30 mins.
You can use the reference TODO-LIst app to try to reproduce the issue.
I just ran a test where on resume my code is making two calls, one to the local db and one to sync gateway. The sync gateway responded with 200, where as the local db is still in “pending” state. This proves to me that the problem is with CBL and not the WebView.
@hideki: It could be that the OS has closed the TCP listener socket. (For comparison, iOS does this when an app has been backgrounded too long and/or the device locks.)
For future reference, if something is definitely going wrong (as in this case), it’s more efficient to report it by filing an issue on Github, rather than posting a thread here.
But in this case it’s a little challenging to determine which product has the issue. I’m wasn’t sure if it’s phonegap plugin, the the java library, or something else.