Edge Sync with Couchbase Lite
Deploy edge clients in a mixed configuration, with HTTP clients accessing data through the REST API and Couchbase Lite clients supporting offline-first data synchronization.
Concepts
Couchbase Lite applications running on mobile and desktop edge clients can synchronize data with a local Edge Server using a WebSocket-based replication protocol.
Couchbase Mobile uses a replication protocol based on WebSockets for replication. To use this protocol the replication URL should specify WebSockets as the URL scheme. See configure target.
You can use Couchbase Lite API support for secure, bi-directional, synchronization of data changes between mobile applications and a central server database such as Couchbase Edge Server. It does so by using a replicator to interact with Sync Gateway.
-
Pull Replication — The process by which clients running Couchbase Lite download database changes from the remote (server) source database to the local target database.
-
Push Replication — The process by which clients running Couchbase Lite upload database changes from the local source database to the remote (server) target database.
Prerequisites
-
If you’re using a self-signed certificate, Couchbase Lite requires a copy of the server’s certificate to set as a pinned cert in the replicator attributes. See certificate pinning.
-
database.enable_client_syncmust not be set tofalsein your configuration schema.
Sync Your Changes
Set enable_client_sync in the database configuration to control the direction of sync between Edge Server and Couchbase Lite clients.
| Value | Behavior |
|---|---|
|
Clients can pull changes from Edge Server. Read-only. |
|
Clients can push changes to Edge Server. Write-only. |
|
Clients can both push and pull changes. |
The following example enables bidirectional sync for a local database.
{
databases: {
travel-sample: {
path: "/var/lib/edge-server/travel-sample.cblite2",
create: true,
enable_client_sync: "bidirectional"
}
},
interface: "0.0.0.0:59840",
users: "/etc/edge-server/users.json"
}
For more information about continuous replication, see Start Replication Automatically.
You can also start replication using the REST API. You do not need to set up replication in the configuration file to do this. Instead, you pass the replication options in the JSON request body.
For more information, see REST API Replication.
For more information about how Couchbase Lite handles downstream replication, see Couchbase Lite - C, Sync.
For information about monitoring and pushing changes, see Push Changes.