Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Getting 401 Unauthorized for replication tasks while the session is still valid on sync gateway #92

Open
chayanbhaisare opened this issue Apr 2, 2017 · 0 comments
Milestone

Comments

@chayanbhaisare
Copy link

chayanbhaisare commented Apr 2, 2017

I am using Couchbase-Lite-PhoneGap-Plugin version 1.3.1 on Android 6.
I am creating the push/pull replication tasks using coax by passing session id as cookie, initially documents gets properly synced to and from sync gateway. But after few hours even with the valid session replication is not working and I am getting following error in adb logcat:

RemoteRequest: com.couchbase.lite.replicator.RemoteRequestRetry@d422b39: isTransientError, httpResponse: Response{protocol=http/1.1, code=401, message=Unauthorized, url=http://syncgateway-url/testdb/_local/97a82cc76d7a1c80674d7f9bc9625e289764c72d} e: com.couchbase.lite.replicator.RemoteRequestResponseException: Unauthorized
W Sync    : com.couchbase.lite.replicator.ReplicationInternal$11@65e86d7: error getting remote checkpoint
W Sync    : com.couchbase.lite.replicator.RemoteRequestResponseException: Unauthorized

D Listener: authHeader is null
D Listener: Unauthorized -- requestCredentials not given or do not match allowed credentials

This error is part of https://github.com/couchbase/couchbase-lite-java-listener/blob/master/src/main/java/com/couchbase/lite/listener/LiteServlet.java#L56-L68
Part of LiteServlet.java code

 String authHeader = req.getHeader("Authorization");
if (authHeader != null) {
   // some code
}else{
     Log.d(Log.TAG_LISTENER, "authHeader is null");
}

Replication config that I am using:
pullRep = {
    source: {
      headers: {
        Cookie: cookie,
      },
      url: config.site.syncUrl,
    },
    target: config.dbName,
  };

This issue is similar to https://github.com/couchbase/couchbase-lite-android/issues/817

@chayanbhaisare chayanbhaisare changed the title Getting 401 Unauthorized for replication while the session is still valid on sync gateway Getting 401 Unauthorized for replication tasks while the session is still valid on sync gateway Apr 2, 2017
@djpongh djpongh added this to the 2.2.0 milestone Apr 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants