ConnectivityManager. TooManyRequestsException

Hi,

I’m using couchbase lite 2.7.0 in my android app. This below error making my app crash. Can anyone help me out.

android.net.ConnectivityManager$TooManyRequestsException: null
    at android.net.ConnectivityManager.convertServiceException(ConnectivityManager.java:3970)
    at android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:4159)
    at android.net.ConnectivityManager.registerDefaultNetworkCallbackForUid(ConnectivityManager.java:4688)
    at android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4655)
    at android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4629)
    at androidx.work.impl.constraints.trackers.NetworkStateTracker.startTracking(NetworkStateTracker.java:89)
    at androidx.work.impl.constraints.trackers.ConstraintTracker.addListener(ConstraintTracker.java:71)
    at androidx.work.impl.constraints.controllers.ConstraintController.replace(ConstraintController.java:99)
    at androidx.work.impl.constraints.WorkConstraintsTracker.replace(WorkConstraintsTracker.java:106)
    at androidx.work.impl.background.greedy.GreedyScheduler.schedule(GreedyScheduler.java:157)
    at androidx.work.impl.background.greedy.DelayedWorkTracker$1.run(DelayedWorkTracker.java:75)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8680)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Do you have any evidence that this has anything to do with Couchbase? The exception looks like a WorkManager callback…

Hi @blake.meike Can you verify below log it seems same as above,

android.net.ConnectivityManager$TooManyRequestsException: null
    at android.net.ConnectivityManager.convertServiceException(ConnectivityManager.java:3970)
    at android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:4159)
    at android.net.ConnectivityManager.registerDefaultNetworkCallbackForUid(ConnectivityManager.java:4688)
    at android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4655)
    at android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4629)
    at com.couchbase.lite.internal.AndroidConnectivityManager$ConnectivityListenerPost28.start(AndroidConnectivityManager.java:245)
    at com.couchbase.lite.internal.AndroidConnectivityManager.start(AndroidConnectivityManager.java:345)
    at com.couchbase.lite.internal.AndroidConnectivityManager.registerObserver(AndroidConnectivityManager.java:299)
    at com.couchbase.lite.internal.replicator.AndroidConnectivityObserver.handleOffline(AndroidConnectivityObserver.java:57)
    at com.couchbase.lite.Replicator.handleOffline(Replicator.java:86)
    at com.couchbase.lite.AbstractReplicator.c4StatusChanged(AbstractReplicator.java:743)
    at com.couchbase.lite.AbstractReplicator$ReplicatorListener.lambda$statusChanged$0(AbstractReplicator.java:255)
    at com.couchbase.lite.-$$Lambda$AbstractReplicator$ReplicatorListener$K9fvruo4ys5Od7V8e4M_8F5AQzk.run
    at com.couchbase.lite.internal.AbstractExecutionService$InstrumentedTask.run(AbstractExecutionService.java:94)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:920)

No, this log is entirely different from the one you posted previously.

There is no way I will have any chance of figuring out what is going on, with only this much information. If you can get me some debug level logging for 30seconds or so, around the time of the failure, I can try to help.

The interesting part is we are seeing lot of errors with this stacktrace in our error tracking tool in production but not able to reproduce it in debug mode. We will try to reproduce this and get back to you with logs. Thanks!

Yes. Would very much appreciate a little more information. In the maintime, I filed CBL-3529 to track this.

… and, as I said, those are two very different stack traces. You are seeing a lot of errors with which one of them?

Hi @blake.meike,

I see this CBL-3529 is marked as fixed in the Jira. Can I know in which this has been fixed? Can we test version?

We see lot of following errors in production when users are at the edge of network which keeps them switching online and offline quite often.

Another question out of curiosity, does continuous replication forces cblite to listen for network change? or cblite listens to network change irrespective of replication sync mode?

android.net.ConnectivityManager$TooManyRequestsException: null
    at android.net.ConnectivityManager.convertServiceException(ConnectivityManager.java:3970)
    at android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:4159)
    at android.net.ConnectivityManager.registerDefaultNetworkCallbackForUid(ConnectivityManager.java:4688)
    at android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4655)
    at android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4629)
    at com.couchbase.lite.internal.AndroidConnectivityManager$ConnectivityListenerPost28.start(AndroidConnectivityManager.java:245)
    at com.couchbase.lite.internal.AndroidConnectivityManager.start(AndroidConnectivityManager.java:345)
    at com.couchbase.lite.internal.AndroidConnectivityManager.registerObserver(AndroidConnectivityManager.java:299)
    at com.couchbase.lite.internal.replicator.AndroidConnectivityObserver.handleOffline(AndroidConnectivityObserver.java:57)
    at com.couchbase.lite.Replicator.handleOffline(Replicator.java:86)
    at com.couchbase.lite.AbstractReplicator.c4StatusChanged(AbstractReplicator.java:743)
    at com.couchbase.lite.AbstractReplicator$ReplicatorListener.lambda$statusChanged$0(AbstractReplicator.java:255)
    at com.couchbase.lite.-$$Lambda$AbstractReplicator$ReplicatorListener$K9fvruo4ys5Od7V8e4M_8F5AQzk.run
    at com.couchbase.lite.internal.AbstractExecutionService$InstrumentedTask.run(AbstractExecutionService.java:94)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:920)

The bug (it is a bug) is fixed in 3.1. I am not involved in setting product release schedules so anything I say about them should, absolutely, be taken with a grain of salt. That said, I do not think there are plans to release another 3.0 version (with a backport of the fix) and I would expect that 3.1 will be released sometime in early 2023.

I have committed the fix and it should be available at the head of the Community Edition source, if that is helpful, in any way.

This is the fix: couchbase-lite-java-common/AndroidConnectivityManager.java at 58cdb636c23ba46a670a266f0a57ae573cbdd892 · couchbase/couchbase-lite-java-common · GitHub