How replications works when cookie expires

I use couchbase-lite-ios with CBLIncrementalStore.

What’s the best practice with a replication when a cookie expires ? When creating a replication, I use this method with my cookie :

- (void) setCookieNamed: (NSString*)name
              withValue: (NSString*)value
                   path: (NSString*)path
         expirationDate: (NSDate*)expirationDate
                 secure: (BOOL)secure;

When the replication fails with a 401 unauthorized error, I call stop on the replication, then I set the new cookie with the previous method, and finally I call start on my replication.

The replication restarts well as you can see these messages :

Pull replication: status = 2, progress = 10 / 10, err = (null)
Push replication: status = 2, progress = 6 / 6, err = (null)

But just after I got this warning :

WARNING: CBLRestPuller["http://x.x.x.x:4984/database"]: 
Unable to save remote checkpoint: Error Domain=CBLHTTP Code=401 "401 unauthorized" UserInfo=0x7bff24b0 
{NSURL="http://x.x.x.x:4984/database/_local/34c763dcd9ef390ee4c763a4e02da675d503166c", NSLocalizedFailureReason=unauthorized, NSLocalizedDescription=401 unauthorized}

Why replications success and this _local fail ?

Does the CBLReplication needs to be deallocated and instantiate with the new cookie ?

I set a 60s ttl on my development environment to see what happens in production when cookie expires, and I saw that.

Is it a problem ? Do I have to create an infinite token to get this problem away ?


The warning is probably coming from the previous (failed) replication, when it attempts to update the remote checkpoint. You can ignore it.

Ok thanks.

Does that mean this failed operation will be tempted again by the new replication ?

Hi @mastohhh,
Yes any failed operation should be tempted again on next sync/replication.