I’m trying to understand how replication works using couchbase-lite-core. So far my understanding tells me that couchbase-lite-core servers both as a local store and a way to communicate with a cloud server. I just don’t understand if I really need to have a sync gateway in the middle. I find a lot of information but nothing very pratical. I know there are probably a lot of concepts and information that I’m still missing but at this point my questions are:
how do I sync a local couchbase-lite-core database with a server?
a) do I use the serverUrl as the remoteUrl
b) do I need to first setup a sync-gateway which will serve as proxy between the local database and the server database?
c) is there any example on how to do that solely with C api?
I have already tried establish a connection. I have ran docker containers with both docker/couchbase-sandbox & docker/couchbase-sync-gateway and tried to create a replicator on the C api with their urls. Both failed with the message:
21:44:33.315045| WARNING: Caught unexpected C++ logic_error("No default C4SocketFactory registered; call c4socket_registerFactory())") Unable to create Replicator for: No default C4SocketFactory registered; call c4socket_registerFactory())
The defacto example of using LiteCore is Couchbase Lite itself.
a) This is the same as the Couchbase Lite setup: Use the URL and database path with the “ws” or “wss” scheme (i.e. ws:///)
b) Yes, you must use sync gateway
c) Not directly no, Couchbase Lite is basically “the example”
You do. That’s the main purpose of Sync Gateway: to act as a replication endpoint.
Both failed with the message:
As the error message says, you need to call c4socket_registerFactory. C4SocketFactory represents a networking implementation. We use different networking libraries on different platforms, so there’s an abstraction layer.
For cross-platform use and testing we have a factory in LiteCore; call RegisterC4CivetWebSocketFactory() (declared in CivetWebSocket.hh) to register it. This function isn’t exported by the DLL so you’ll need to be statically linking with LiteCore to use it.
Note: CivetWebSocketFactory doesn’t support TLS/SSL.
Jens, thanks for the reply and for the extra info. I have been able to successfully register C4CivetWebSocketFactory. I have a sync-gateway running and it seems to be connecting successfully:
Thank you! Another milestone achieved. I still need to learn about working with the sync gateway, and then with the server it self. There is a lot of information to absorve and I can’t seem to find a complete and comprehensive, straight to the point, quick start guide covering the full process.