I’ve been looking into using CBL as an on-disk cache with a very low overhead for my microservice application. As part of this I want to keep two databases across two services in sync. For now I have been testing CBL with simple Windows console applications, and I have successfully gotten two apps to talk to each other when creating documents. My current problem is that I can’t seem to get a document delete function to replicate from the first app to the second.
I have the following 2 programs:
-
CouchbaseLite1 - Sets up of a listener
https://gist.github.com/PaulMilla/336f53ef4c72917832d35dc74d68ce9e -
CouchbaseLite2 - Connects to the listener and creates pull/push replications
https://gist.github.com/PaulMilla/e46a690d06700da8aa2e317f0c7568b3
What’s weird is that I can replicate a delete from CouchbaseLite2 to CouchbaseLite1, but not vice versa. Doing so gives me the following log (from CouchbaseLite2):
2017-04-26 20:15:42,171|INFO |CHANGE TRACKER (ChangeTracker)|SocketChangeTracker[app1] [Couchbase Lite .NET Microsoft Windows 7 Enterprise/x64 1.4.0: Version=c2ddc0c]
2017-04-26 20:15:42,178|DEBUG|CHANGE TRACKER (ChangeTracker)|SocketChangeTracker[app1]
2017-04-26 20:15:42,180|DEBUG|CHANGE TRACKER (OneShotOrLongPollLogic)|Couchbase.Lite.Internal.OneShotOrLongPollLogic
2017-04-26 20:15:42,181|DEBUG|CHANGE TRACKER (SocketChangeTracker)|SocketChangeTracker[app1]
2017-04-26 20:15:42,182|INFO |SYNC (Puller)|1 4 0 1 Puller a13e5e9e-7933-4c67-9f11-a4adb22b6a94
2017-04-26 20:15:42,193|DEBUG|CHANGE TRACKER (SocketChangeTracker)|http://127.0.0.1:59840/app1/_changes?feed=longpoll&heartbeat=300000&style=all_docs&since=4
2017-04-26 20:15:42,236|INFO |SYNC (Puller)|Puller a13e5e9e-7933-4c67-9f11-a4adb22b6a94 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(Task`1 request, Object state)
at Couchbase.Lite.Util.TransientErrorRetryHandler.<ResendHandler>c__AnonStorey0.<>m__0(Task`1 t)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
at Couchbase.Lite.CouchbaseLiteHttpClient.<SendAsync>c__AnonStorey2.<>m__1(Task`1 t)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
---> (Inner Exception #0) [HttpResponseException: StatusCode = NotFound]<---
2017-04-26 20:15:42,247|INFO |SYNC (Replication)|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(Task`1 request, Object state)
at Couchbase.Lite.Util.TransientErrorRetryHandler.<ResendHandler>c__AnonStorey0.<>m__0(Task`1 t)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
at Couchbase.Lite.CouchbaseLiteHttpClient.<SendAsync>c__AnonStorey2.<>m__1(Task`1 t)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
---> (Inner Exception #0) [HttpResponseException: StatusCode = NotFound]<---
Note: I have already authorized the URL as an admin for Windows (I was getting a different error before that)