How to listen to event of CBL replications become inactive?

It seems after idle for a while, the status of CBL’s continueous push&pull replications always become non-active, this makes expected replications silently fail from that point on. I was wondering how do iOS and Android clients listen/observe this event ( replication status change to non-active) so that I can make it active again? Or is there an option to keep replications active forever even if it maybe idle for a while?

If you could provide some sample code for this, that would be much appreciated!

Also, if you could share what factors determines the automatic change of status of continueous replications, that would very helpful too!

Thanks a lot !

If you could provide any information at all about the version of CBL that you are using, the platform you are running on, or the why you think that the replicators are “becoming non-active”, perhaps we could be helpful.

@blake.meike Sure:
CBL version is 1.4.1 on iOS,
Sync Gateway version is 1.5.1 on Ubuntu 14.04,
Couchbase Server versions (that Have been tested) are 5.1.1 on CentOS 7 and 7.0.1 on Debian 10,

Reason why I think replicators become non-active:

Two iOS CBL clients A and B setup continueous push and pull replications to a particular channel upon launching the app. In the first few minutes after app launch, new docs (and update to existing docs) from A are received by B as expected. However, after letting the iOS client B 's app open and idle (nothing going on, i.e. no replication event) for about 10 minutes, subsequent updates from A will not be received by B. At this point, if I run code like below on B, B can receive updates from A again:

If pushReplication.status != .active {

If pullReplication.status != .active {

This is why I think the issue is the replications’ status automatically change to a non-active status after app idle for a while.

Feel free to ask if you need additional info.

A related question is: is the connection between CBL and Sync Gateway a TCP connection? If so, is that TCP connection meant to last forever (by forever I mean the connection keeps alive as long as the app is in foreground) if there are continueous replications set up on CBL side?

Thanks a lot !

@lordofming : v1.4 is very old and not maintained anymore. My first suggestion is that you move to a more recent version (we release v2.8 a while ago).

Yes, it is a TCP connection. Not sure about v 1.4 (it is ancient and before my time, here at CB), but current versions use a WebSocket connection. My first guess would be that either the devices themselves (the phones, I’m guessing) or some NAT device between the devices and the SGW, is tearing down the connection after time limit.

I’m the Android guy, here, so I’m going to leave this for one of my colleagues, more familiar with iOS. I think it would be very useful to see the logs that show the replicator status change. If you could post them here, when my colleague gets a chance to look at thread, they will be much more able to help.