Xamarin: Push/Pull Replication not working for me

I’m working on a Xamaring CrossPlateform App. We are working on a team enviornment using GIT ( MS Team Services ). When Setup on App everything works with couchbase Lite. But Sync Gateway Push and Pull Relication isn’t working.
I’m using Sync Gateway v1.4 and Coucbase 4.6 . Below are the Logs from Visual Studio:

[0:] INFO) SYNC (Replication): [7] 2017-7-28 01:33:35.461+05:30 Attempting to start pusher (18b2f301-6a32-46ab-ad14-f934bfdb8712)
[0:] INFO) SYNC (Replication): [7] 2017-7-28 01:33:35.466+05:30 Attempting to start puller (f23d9f40-5adc-4e81-af82-19d3358ffdfd)
[0:] INFO) SYNC (Replication): [7] 2017-7-28 01:33:36.152+05:30 Beginning replication process…
[0:] INFO) SYNC (Replication): [7] 2017-7-28 01:33:36.237+05:30 Pusher 18b2f301-6a32-46ab-ad14-f934bfdb8712 successfully logged in!
[0:] INFO) SYNC (Replication): [7] 2017-7-28 01:33:36.404+05:30 Pusher 18b2f301-6a32-46ab-ad14-f934bfdb8712 no local checkpoint, not getting remote one
[0:] INFO) SYNC (Replication): [7] 2017-7-28 01:33:36.448+05:30 Beginning replication process…
[0:] INFO) SYNC (Replication): [7] 2017-7-28 01:33:36.465+05:30 Puller f23d9f40-5adc-4e81-af82-19d3358ffdfd successfully logged in!
[0:] INFO) SYNC (Replication): [7] 2017-7-28 01:33:36.469+05:30 Puller f23d9f40-5adc-4e81-af82-19d3358ffdfd no local checkpoint, not getting remote one
[0:] INFO) SYNC (Puller): [7] 2017-7-28 01:33:36.479+05:30 Puller f23d9f40-5adc-4e81-af82-19d3358ffdfd will use MaxOpenHttpConnections(8), MaxRevsToGetInBulk(50)
[0:] WARN) SYNC (RemoteSession): [5] 2017-7-28 01:33:37.998+05:30 Http Message failed to send, or got error response, passing to callback… http://{HOSTNAME REPLACE FOR SECURITY REASONS}/_revs_diff, :
System.AggregateException: One or more errors occurred. —> 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.Task1[TResult] request, System.Object state) [0x0017d] in <bb3bb8c4fbb54f939fa09402030f6081>:0 at Couchbase.Lite.Util.TransientErrorRetryHandler+<ResendHandler>c__AnonStorey0.<>m__0 (System.Threading.Tasks.Task1[TResult] t) <0x98fb6a80 + 0x0003b> in :0
at System.Threading.Tasks.ContinuationResultTaskFromResultTask2[TAntecedentResult,TResult].InnerInvoke () [0x00024] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Threading.Tasks.Task.Execute () [0x00010] in <3fd174ff54b146228c505f23cf75ce71>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Net.Http.HttpClient+d__49.MoveNext () [0x000ca] in :0
— End of inner exception stack trace —
at Couchbase.Lite.CouchbaseLiteHttpClient+c__AnonStorey2.<>m__1 (System.Threading.Tasks.Task1[TResult] t) [0x00000] in /Volumes/Data/jenkins/workspace/couchbase-lite-net-build@2/1.4/Android/couchbase-lite-net/src/Couchbase.Lite.Shared/Replication/ChangeTracker.cs:70 at System.Threading.Tasks.ContinuationResultTaskFromResultTask2[TAntecedentResult,TResult].InnerInvoke () [0x00024] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Threading.Tasks.Task.Execute () [0x00010] in <3fd174ff54b146228c505f23cf75ce71>:0
— End of inner exception stack trace —
—> (Inner Exception #0) 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.Task1[TResult] request, System.Object state) [0x0017d] in <bb3bb8c4fbb54f939fa09402030f6081>:0 at Couchbase.Lite.Util.TransientErrorRetryHandler+<ResendHandler>c__AnonStorey0.<>m__0 (System.Threading.Tasks.Task1[TResult] t) <0x98fb6a80 + 0x0003b> in :0
at System.Threading.Tasks.ContinuationResultTaskFromResultTask2[TAntecedentResult,TResult].InnerInvoke () [0x00024] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Threading.Tasks.Task.Execute () [0x00010] in <3fd174ff54b146228c505f23cf75ce71>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Net.Http.HttpClient+d__49.MoveNext () [0x000ca] in :0
— End of inner exception stack trace —
at Couchbase.Lite.CouchbaseLiteHttpClient+c__AnonStorey2.<>m__1 (System.Threading.Tasks.Task1[TResult] t) [0x00000] in /Volumes/Data/jenkins/workspace/couchbase-lite-net-build@2/1.4/Android/couchbase-lite-net/src/Couchbase.Lite.Shared/Replication/ChangeTracker.cs:70 at System.Threading.Tasks.ContinuationResultTaskFromResultTask2[TAntecedentResult,TResult].InnerInvoke () [0x00024] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Threading.Tasks.Task.Execute () [0x00010] in <3fd174ff54b146228c505f23cf75ce71>:0
—> (Inner Exception #0) [HttpResponseException: StatusCode = NotFound]<—
<—
[0:] WARN) SYNC (RemoteSession): [5] 2017-7-28 01:33:38.018+05:30 Failed content:
[0:] INFO) CHANGE TRACKER (SocketChangeTracker): [5] 2017-7-28 01:33:38.025+05:30 SocketChangeTracker[/] cannot recover, stopping…
[0:] INFO) SYNC (Replication): [5] 2017-7-28 01:33:38.030+05:30 Error set during replication (application may continue):
[HttpResponseException: StatusCode = NotFound]
Thread finished: #8
[0:] INFO) CHANGE TRACKER (SocketChangeTracker): [5] 2017-7-28 01:33:38.039+05:30 Stopping SocketChangeTracker[/]…
[0:] INFO) SYNC (Puller): [5] 2017-7-28 01:33:38.049+05:30 Change tracker for f23d9f40-5adc-4e81-af82-19d3358ffdfd stopped; error=[HttpResponseException: StatusCode = NotFound]
[0:] INFO) SYNC (Replication): [5] 2017-7-28 01:33:38.053+05:30 Error set during replication (application may continue):
[HttpResponseException: StatusCode = NotFound]
[0:] INFO) SYNC (Replication): [5] 2017-7-28 01:33:38.086+05:30 f23d9f40-5adc-4e81-af82-19d3358ffdfd: Stop Graceful…
[0:] INFO) SYNC (Replication): [5] 2017-7-28 01:33:38.130+05:30 Puller f23d9f40-5adc-4e81-af82-19d3358ffdfd Stopping
The thread ‘Unknown’ (0x8) has exited with code 0 (0x0).
[0:] INFO) SYNC (Replication): [5] 2017-7-28 01:33:38.160+05:30 Puller f23d9f40-5adc-4e81-af82-19d3358ffdfd checkpointing sequence=0
[0:] WARN) SYNC (RemoteSession): [5] 2017-7-28 01:33:38.676+05:30 Http Message failed to send, or got error response, passing to callback… http://{HOSTNAME REPLACE FOR SECURITY REASONS}/_local/9a50d2a79d6ceab29e693b77cfd7f45a73c5a5b4, :
System.AggregateException: One or more errors occurred. —> 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.Task1[TResult] request, System.Object state) [0x0017d] in <bb3bb8c4fbb54f939fa09402030f6081>:0 at Couchbase.Lite.Util.TransientErrorRetryHandler+<ResendHandler>c__AnonStorey0.<>m__0 (System.Threading.Tasks.Task1[TResult] t) <0x98fb6a80 + 0x0003b> in :0
at System.Threading.Tasks.ContinuationResultTaskFromResultTask2[TAntecedentResult,TResult].InnerInvoke () [0x00024] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Threading.Tasks.Task.Execute () [0x00010] in <3fd174ff54b146228c505f23cf75ce71>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Net.Http.HttpClient+d__49.MoveNext () [0x000ca] in :0
— End of inner exception stack trace —
at Couchbase.Lite.CouchbaseLiteHttpClient+c__AnonStorey2.<>m__1 (System.Threading.Tasks.Task1[TResult] t) [0x00000] in /Volumes/Data/jenkins/workspace/couchbase-lite-net-build@2/1.4/Android/couchbase-lite-net/src/Couchbase.Lite.Shared/Replication/ChangeTracker.cs:70 at System.Threading.Tasks.ContinuationResultTaskFromResultTask2[TAntecedentResult,TResult].InnerInvoke () [0x00024] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Threading.Tasks.Task.Execute () [0x00010] in <3fd174ff54b146228c505f23cf75ce71>:0
— End of inner exception stack trace —
—> (Inner Exception #0) 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.Task1[TResult] request, System.Object state) [0x0017d] in <bb3bb8c4fbb54f939fa09402030f6081>:0 at Couchbase.Lite.Util.TransientErrorRetryHandler+<ResendHandler>c__AnonStorey0.<>m__0 (System.Threading.Tasks.Task1[TResult] t) <0x98fb6a80 + 0x0003b> in :0
at System.Threading.Tasks.ContinuationResultTaskFromResultTask2[TAntecedentResult,TResult].InnerInvoke () [0x00024] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Threading.Tasks.Task.Execute () [0x00010] in <3fd174ff54b146228c505f23cf75ce71>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Net.Http.HttpClient+d__49.MoveNext () [0x000ca] in :0
— End of inner exception stack trace —
at Couchbase.Lite.CouchbaseLiteHttpClient+c__AnonStorey2.<>m__1 (System.Threading.Tasks.Task1[TResult] t) [0x00000] in /Volumes/Data/jenkins/workspace/couchbase-lite-net-build@2/1.4/Android/couchbase-lite-net/src/Couchbase.Lite.Shared/Replication/ChangeTracker.cs:70 at System.Threading.Tasks.ContinuationResultTaskFromResultTask2[TAntecedentResult,TResult].InnerInvoke () [0x00024] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Threading.Tasks.Task.Execute () [0x00010] in <3fd174ff54b146228c505f23cf75ce71>:0
—> (Inner Exception #0) [HttpResponseException: StatusCode = NotFound]<—
<—
[0:] WARN) SYNC (RemoteSession): [5] 2017-7-28 01:33:38.709+05:30 Failed content:
[0:] INFO) SYNC (Replication): [5] 2017-7-28 01:33:38.716+05:30 Got 404 from _local, ignoring…
[0:] INFO) SYNC (Replication): [6] 2017-7-28 01:33:38.747+05:30 Puller f23d9f40-5adc-4e81-af82-19d3358ffdfd stopped. Elapsed time 2.280 sec
07-28 13:34:15.902 D/Mono ( 3902): [0x9b1bf930] worker finishing
Thread finished: #5
The thread ‘Unknown’ (0x5) has exited with code 0 (0x0).
Thread finished: #2
Thread started: #10
The thread ‘Unknown’ (0x2) has exited with code 0 (0x0).
07-28 13:34:38.070 D/Mono ( 3902): [0x9b36d930] hill climbing, change max number of threads 2
[0:] INFO) SYNC (Replication): [5] 2017-7-28 01:34:38.076+05:30 RETRYING, to transfer missed revisions…
[0:] INFO) SYNC (Replication): [5] 2017-7-28 01:34:38.112+05:30 Error set during replication (application may continue)
[0:] INFO) SYNC (Replication): [5] 2017-7-28 01:34:38.119+05:30 Error set during replication (application may continue):

[0:] INFO) SYNC (Replication): [5] 2017-7-28 01:34:38.132+05:30 Pusher 18b2f301-6a32-46ab-ad14-f934bfdb8712 successfully logged in!
[0:] INFO) SYNC (Replication): [5] 2017-7-28 01:34:38.136+05:30 Pusher 18b2f301-6a32-46ab-ad14-f934bfdb8712 no local checkpoint, not getting remote one

My Code for C# is as below for Replication:

Log.Debug(TAG, "Entering method StartReplicationWithAuth");
pull = db.CreatePullReplication(CreateSyncUri(host, port));
push = db.CreatePushReplication(CreateSyncUri(host, port));
var authenticator = AuthenticatorFactory.CreateBasicAuthenticator(Constant.DB_USER, Constant.DB_PASS);
pull.Authenticator = authenticator;
push.Authenticator = authenticator;
pull.Continuous = true;
push.Continuous = true;
push.Changed += (sender, e) =>
{
            // Will be called when the push replication status changes
};
pull.Changed += (sender, e) =>
{
            // Will be called when the pull replication status changes
};
pull.Start();
push.Start();
Log.Debug(TAG, "Exiting method StartReplicationWithAuth");

Hi @dm.gurmeet

@borrrden is our resident .NET light engineer, he should be able to help you.

1 Like

Thanks Mike.
@borrrden Any Help would be appriciated.

This is the server category by the way. However this information is not much to go on without knowing the circumstances (i.e. did replication ever work?). It appears that 404 is being returned from the gateway. Can you verify that it is accessible?

HI @borrrden,

Thanks for your reply. Our server is configured as pod under Openshift. I even tried it under VM as well. to explain this more let me tell you further on this. I have local couchbase server ( community 4.5 with sync gateway working ) and earlier my replication code worked with this server. Then I configured the code to work with online server ( under Openshift Pod Couchbase Enterprise 4.6.2 ). Replication didn’t worked there. I tried connecting local couchbase server. And now it’s not working as well.

Can you verify that it is accessible?
Yes I can access sync Gateway publically. But I’m not sure sync gateway can access couchbase server ( I’ll verify that ) since both sync gateway and couchbase servers are different pods under openshift.

Okay @borrrden Sync Gateway is able to connect to couchbase server fine and sync gateway is also publically accessible. but it is configured to work on port 80.
is that an issue?

You mean you configured Sync Gateway to serve public requests on port 80? That shouldn’t be a problem but don’t forget to alter your port in your replication to 80 as well.

yeah it’s working on 80 port and is configured. I got the sync working as well. But what I did was not really what I was looking for. I did the followings:
1: I created sync file again ( no channels yet )
2: I deleted the bucket on the server and created a new bucket
3: updated sync gateway config file with new bucket name
4: Deleted existing app from device/emulator and tried sync again

these steps worked for me and started sync fine. But I still don’t know what was the issue with previous existing bucket.

thanks