Replication Changed Event Not capturing 401 Unauthorized

Hello!

I’ve gone through the forum posts and issues, and I think that this has been resolved, but strangely, I’m facing it again.

Here’s what I’m doing and what’s happening:

  1. Developing on the C# API (.NET, v1.4.0). I’m using custom authentication
  2. I have the same user logged in at once in two different devices
  3. When I change the password on one device, the other device fails to catch the Unauthorized exception through the Changed event for Replicators. However, the logs show [HttpResponseException: StatusCode = Unauthorized]
  4. The event fires only when the app is relaunched.

My code for the change event:

if (e.LastError != null)
	{
		Exception error = e.LastError;
		if (error is HttpResponseException)
		{
			HttpResponseException exception = (HttpResponseException)error;
			if ((int)exception.StatusCode == 401)
			{
				 AppLog.WriteLogE(TAG, "Authentication error");
				 Puller.Changed -= HandleChange;
				 Pusher.Changed -= HandleChange;
				 if (!isUnauthAlertShowing)
					DisplayUnauthorizedAlert();
				    }
				   activityIndicator.StopAnimating();
			}
	}
			//if (rep.LastError != null) {
			//	Exception error = rep.LastError;
			//	if (error is HttpResponseException) {
			//		HttpResponseException exception = (HttpResponseException)error;
			//		if ((int)exception.StatusCode == 401) {
			//			AppLog.WriteLogD(TAG, "Replication Auth Error");
			//		}
			//	}
			//}
		else if (Puller.Status == ReplicationStatus.Active)
		{
			activityIndicator.StartAnimating();
			AppLog.WriteLogD(TAG, "Pull in Progress");
		}
		else if (Pusher.Status == ReplicationStatus.Active)
		{
			activityIndicator.StartAnimating();
			AppLog.WriteLogD(TAG, "Push in Progress");
		}
		else
		{
			AppLog.WriteLogD(TAG, "Completed Changes Count: ", e.CompletedChangesCount.ToString());
			AppLog.WriteLogD(TAG, "Changes Count: ", e.ChangesCount.ToString());
			activityIndicator.StopAnimating();
		}

I tried listening to the error through rep.LastError but this too doesn’t give me the desired event.

BTW, does the session expiration time for user’s session get updated with each replication request? I think I read that somewhere but can’t say for sure.

What kind of authentication are you using? HTTP Basic doesn’t create a session, I think, but if it does then the expiration is controlled by the other side (Sync Gateway). It would be helpful to show the logging you mentioned and file a ticket on the .NET repo so I can try to get it reproduced.

Here’s what my colleague told me about how authentication is being handled :

We are using custom authentication. The sign-in api (to custom server) will first check if there is valid session in the sync gateway using Admin API for that user. If session is found, it will return the session_id and other details. If not, it will create a session for that user using same session Admin API and returns the session details to mobile client.

And here’s the log:

INFO) CHANGE TRACKER (ChunkedChanges): [18] 2017-4-11 11:18:08.481+05:45 Parse found 1 changes
INFO) CHANGE TRACKER (ChunkedChanges): [18] 2017-4-11 11:18:08.481+05:45 Parsed [{"seq":2310,"id":"_user/thmt@ucupdong.ml","changes":[]}] (nested count: 0)

INFO) CHANGE TRACKER (ChunkedChanges): [21] 2017-4-11 11:18:15.431+05:45 Parse found 1 changes
2017-04-11 11:18:15.435 HHA.iOS[4421:427668] ViewController Pull in Progress
INFO) CHANGE TRACKER (ChunkedChanges): [21] 2017-4-11 11:18:15.435+05:45 Parsed [{"seq":"2308::2312","id":"c2bec2a7c2be04c3a1c28261c3003cf5","changes":[{"rev":"104-2dda06362168dedded499c0810c1389b"},{"rev":"24-1c894a0156f7fae32b6f43901b0e20dc"},{"rev":"30-54630dd6dc3c2b0d7ba40f9ba97e9202"},{"rev":"96-1fa33f6f4763e7b23e4e65676f37fe31"}]}] (nested count: 0)
INFO) SYNC (Puller): [23] 2017-4-11 11:18:15.437+05:45 Puller 4214622c-0c81-4e93-b1f9-a4f8c177981a Removed 3 already present revisions
2017-04-11 11:18:15.439 HHA.iOS[4421:427668] ViewController Pull in Progress
INFO) SYNC (Puller): [21] 2017-4-11 11:18:15.439+05:45 Puller 4214622c-0c81-4e93-b1f9-a4f8c177981a queued 1 remote revisions from seq=2308::2312 (1 in bulk, 0 individually)
INFO) SYNC (Puller): [22] 2017-4-11 11:18:15.747+05:45 Puller 4214622c-0c81-4e93-b1f9-a4f8c177981a error pulling remote revision:
System.AggregateException: One or more errors occurred. ---> Couchbase.Lite.HttpResponseException: Exception of type 'Couchbase.Lite.HttpResponseException' was thrown.
  at Couchbase.Lite.Util.TransientErrorRetryHandler.HandleTransientErrors (System.Threading.Tasks.Task`1[TResult] request, System.Object state) [0x0017d] in <e5b79a78826c468cbaff337ac9997202>:0 
  at Couchbase.Lite.Util.TransientErrorRetryHandler+<ResendHandler>c__AnonStorey0.<>m__0 (System.Threading.Tasks.Task`1[TResult] t) <0x234c55b8 + 0x00033> in <e5b79a78826c468cbaff337ac9997202>:0 
  at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2[TAntecedentResult,TResult].InnerInvoke () [0x00027] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/TaskContinuation.cs:207 
  at System.Threading.Tasks.Task.Execute () [0x00016] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 
  at System.Net.Http.HttpClient+<SendAsyncWorker>c__async0.MoveNext () [0x000a9] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:276 
   --- End of inner exception stack trace ---
  at Couchbase.Lite.CouchbaseLiteHttpClient+<SendAsync>c__AnonStorey2.<>m__1 (System.Threading.Tasks.Task`1[TResult] t) [0x00000] in /Users/jenkins/jenkins/workspace/couchbase-lite-net-build/1.4/iOS/couchbase-lite-net/src/Couchbase.Lite.Shared/Replication/ChangeTracker.cs:70 
  at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2[TAntecedentResult,TResult].InnerInvoke () [0x00027] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/TaskContinuation.cs:207 
  at System.Threading.Tasks.Task.Execute () [0x00016] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 
---> (Inner Exception #0) [HttpResponseException: StatusCode = Unauthorized]<---

INFO) SYNC (Replication): [22] 2017-4-11 11:18:15.754+05:45 Error set during replication (application may continue):
System.AggregateException: One or more errors occurred. ---> Couchbase.Lite.HttpResponseException: Exception of type 'Couchbase.Lite.HttpResponseException' was thrown.
  at Couchbase.Lite.Util.TransientErrorRetryHandler.HandleTransientErrors (System.Threading.Tasks.Task`1[TResult] request, System.Object state) [0x0017d] in <e5b79a78826c468cbaff337ac9997202>:0 
  at Couchbase.Lite.Util.TransientErrorRetryHandler+<ResendHandler>c__AnonStorey0.<>m__0 (System.Threading.Tasks.Task`1[TResult] t) <0x234c55b8 + 0x00033> in <e5b79a78826c468cbaff337ac9997202>:0 
  at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2[TAntecedentResult,TResult].InnerInvoke () [0x00027] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/TaskContinuation.cs:207 
  at System.Threading.Tasks.Task.Execute () [0x00016] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 
  at System.Net.Http.HttpClient+<SendAsyncWorker>c__async0.MoveNext () [0x000a9] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:276 
   --- End of inner exception stack trace ---
  at Couchbase.Lite.CouchbaseLiteHttpClient+<SendAsync>c__AnonStorey2.<>m__1 (System.Threading.Tasks.Task`1[TResult] t) [0x00000] in /Users/jenkins/jenkins/workspace/couchbase-lite-net-build/1.4/iOS/couchbase-lite-net/src/Couchbase.Lite.Shared/Replication/ChangeTracker.cs:70 
  at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2[TAntecedentResult,TResult].InnerInvoke () [0x00027] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/TaskContinuation.cs:207 
  at System.Threading.Tasks.Task.Execute () [0x00016] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.6.0.10/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 
---> (Inner Exception #0) [HttpResponseException: StatusCode = Unauthorized]<---

That’s odd. That log line is a result of this, and you can see two lines later it sends out a notification. Are you running any other replications and accidentally monitoring those?

I don’t think there are other replications, but here’s what I’m doing :

I have a class CouchbaseHelper.cs where I do all initialization and setting up sync.

I have Replications set as follows :

public Replication pull { get; set;}
public Replication push { get; set; }

Sync Method:

public void SyncDatabase(Database db)
{
	var syncUri = new Uri(Constants.BASE_URL_SYNC);
	string username, password;
#if __IOS__
	Couchbase.Lite.Storage.SystemSQLite.Plugin.Register();
	username = NSUserDefaults.StandardUserDefaults.StringForKey(Constants.USERNAME_KEY);
	password = NSUserDefaults.StandardUserDefaults.StringForKey(Constants.PASSWORD_KEY);
#endif
	AppLog.WriteLogD(TAG, username, password);
	var authenticator = AuthenticatorFactory.CreateBasicAuthenticator(username, password);
	pull = db.CreatePullReplication(syncUri);
	pull.Authenticator = authenticator;
	pull.Continuous = true;
	pull.Start();

	push = db.CreatePushReplication(syncUri);
	push.Authenticator = authenticator;
	push.Continuous = true;
	push.Start();
}

In my first ViewController I initialize the CouchbaseHelper, initialize database, and start sync.

cbHelper = new CouchbaseHelper();
Database = cbHelper.InitCouchbase(NSUserDefaults.StandardUserDefaults.StringForKey(Constants.USER_ID_KEY));
cbHelper.SyncDatabase(Database);

Then I get the puller/pusher from a method of the CouchbaseHelper as :

public Replication GetPuller() {
			return pull;
		}

public Replication GetPusher() {
			return push;
		}

Puller = cbHelper.GetPuller();
Pusher = cbHelper.GetPusher(); 

Pusher.Changed += HandleChange;
Puller.Changed += HandleChange;

You can see the HandleChange in my first post.

That doesn’t reflect what you said above:

We are using custom authentication. The sign-in api (to custom server) will first check if there is valid session in the sync gateway using Admin API for that user. If session is found, it will return the session_id and other details. If not, it will create a session for that user using same session Admin API and returns the session details to mobile client.

The code you showed just uses HTTP Basic Auth. Anyway, are any exceptions coming through at all? It’s possible that they are nested or of a different type.

Hmm. I guess we’ll need to setup custom auth for the mobile client then. Will try and see what happens once that’s done.

Anyways, even when using a basic HTTP authenticator, shouldn’t the change event capture the unauthorized exception?

Could you please tell what other exceptions you’re referring to? At the moment, the only exception I can see in the logs is in the scenario I’ve described.

Yes you should get the exception in any case. The logs indicate that the exception was sent to the Changed event so it’s puzzling why you don’t see it.

What I mean by “other exceptions” is that you check if (error is HttpResponseException) but ignore it otherwise. Is the exception null or is it another type?

What I Did :

if (e.LastError != null)
			{
				Exception error = e.LastError;
				AppLog.WriteLogD(TAG, "StackTrace: ",error.StackTrace);
                                AppLog.WriteLogD(TAG, "Error: ", error.ToString());
				if (error is HttpResponseException)
				{...
                                    }

The logs:

 StackTrace:    at Couchbase.Lite.CouchbaseLiteHttpClient+<SendAsync>c__AnonStorey2.<>m__1 (System.Threading.Tasks.Task`1[TResult] t) [0x00000] in /Users/jenkins/jenkins/workspace/couchbase-lite-net-build/1.4/iOS/couchbase-lite-net/src/Couchbase.Lite.Shared/Replication/ChangeTracker.cs:70 
  at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2[TAntecedentResult,TResult].InnerInvoke () [0x00027] in <54e129cad3ee4c61a6b46c3680ddc69a>:0 
  at System.Threading.Tasks.Task.Execute () [0x00016] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 
2017-04-13 12:28:37.159 HHA.iOS[947:1074014] PayerDashboardController Error: System.AggregateException: One or more errors occurred. ---> Couchbase.Lite.HttpResponseException: Exception of type 'Couchbase.Lite.HttpResponseException' was thrown.
  at Couchbase.Lite.Util.TransientErrorRetryHandler.HandleTransientErrors (System.Threading.Tasks.Task`1[TResult] request, System.Object state) [0x0017d] in <e5b79a78826c468cbaff337ac9997202>:0 
  at Couchbase.Lite.Util.TransientErrorRetryHandler+<ResendHandler>c__AnonStorey0.<>m__0 (System.Threading.Tasks.Task`1[TResult] t) <0x100477f30 + 0x00047> in <e5b79a78826c468cbaff337ac9997202#9aad994fb29032526687f22ec7899c61>:0 
  at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2[TAntecedentResult,TResult].InnerInvoke () [0x00027] in <54e129cad3ee4c61a6b46c3680ddc69a>:0 
  at System.Threading.Tasks.Task.Execute () [0x00016] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <54e129cad3ee4c61a6b46c3680ddc69a>:0 
  at System.Net.Http.HttpClient+<SendAsyncWorker>c__async0.MoveNext () [0x000a9] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:276 
   --- End of inner exception stack trace ---
  at Couchbase.Lite.CouchbaseLiteHttpClient+<SendAsync>c__AnonStorey2.<>m__1 (System.Threading.Tasks.Task`1[TResult] t) [0x00000] in /Users/jenkins/jenkins/workspace/couchbase-lite-net-build/1.4/iOS/couchbase-lite-net/src/Couchbase.Lite.Shared/Replication/ChangeTracker.cs:70 
  at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2[TAntecedentResult,TResult].InnerInvoke () [0x00027] in <54e129cad3ee4c61a6b46c3680ddc69a>:0 
  at System.Threading.Tasks.Task.Execute () [0x00016] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 
---> (Inner Exception #0) [HttpResponseException: StatusCode = Unauthorized]<---

Error: System.AggregateException: One or more errors occurred. ---> Couchbase.Lite.HttpResponseException: Exception of type 'Couchbase.Lite.HttpResponseException' was thrown.
      at Couchbase.Lite.Util.TransientErrorRetryHandler.HandleTransientErrors (System.Threading.Tasks.Task`1[TResult] request, System.Object state) [0x0017d] in <e5b79a78826c468cbaff337ac9997202>:0 
      at Couchbase.Lite.Util.TransientErrorRetryHandler+<ResendHandler>c__AnonStorey0.<>m__0 (System.Threading.Tasks.Task`1[TResult] t) <0x10046ff30 + 0x00047> in <e5b79a78826c468cbaff337ac9997202#9f5e0cb8f4ac374de91fc190dbc898f4>:0 
      at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2[TAntecedentResult,TResult].InnerInvoke () [0x00027] in <54e129cad3ee4c61a6b46c3680ddc69a>:0 
      at System.Threading.Tasks.Task.Execute () [0x00016] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 
    --- End of stack trace from previous location where exception was thrown ---
      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
      at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
      at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
      at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <54e129cad3ee4c61a6b46c3680ddc69a>:0 
      at System.Net.Http.HttpClient+<SendAsyncWorker>c__async0.MoveNext () [0x000a9] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:276 
       --- End of inner exception stack trace ---
      at Couchbase.Lite.CouchbaseLiteHttpClient+<SendAsync>c__AnonStorey2.<>m__1 (System.Threading.Tasks.Task`1[TResult] t) [0x00000] in /Users/jenkins/jenkins/workspace/couchbase-lite-net-build/1.4/iOS/couchbase-lite-net/src/Couchbase.Lite.Shared/Replication/ChangeTracker.cs:70 
      at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2[TAntecedentResult,TResult].InnerInvoke () [0x00027] in <54e129cad3ee4c61a6b46c3680ddc69a>:0 
      at System.Threading.Tasks.Task.Execute () [0x00016] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 
    ---> (Inner Exception #0) [HttpResponseException: StatusCode = Unauthorized]<--- 

When the app is relaunched (and when the event correctly shows unauth alert:)

StackTrace:    at Couchbase.Lite.Util.TransientErrorRetryHandler.HandleTransientErrors (System.Threading.Tasks.Task`1[TResult] request, System.Object state) [0x0017d] in <e5b79a78826c468cbaff337ac9997202>:0 
  at Couchbase.Lite.Util.TransientErrorRetryHandler+<ResendHandler>c__AnonStorey0.<>m__0 (System.Threading.Tasks.Task`1[TResult] t) <0x100497f30 + 0x00047> in <e5b79a78826c468cbaff337ac9997202#9aad994fb29032526687f22ec7899c61>:0 
  at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2[TAntecedentResult,TResult].InnerInvoke () [0x00027] in <54e129cad3ee4c61a6b46c3680ddc69a>:0 
  at System.Threading.Tasks.Task.Execute () [0x00016] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <54e129cad3ee4c61a6b46c3680ddc69a>:0 
  at System.Net.Http.HttpClient+<SendAsyncWorker>c__async0.MoveNext () [0x000a9] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:276

Error: [HttpResponseException: StatusCode = Unauthorized]