Search code examples
c#xamarinsynchronizationcouchbasecouchbase-sync-gateway

Sync gateway is not syncing with Couchbase server in Xamarin


I am trying to use couchbase for online and offline database in my xamarin application . the offline part is working good , but it doesn't sync .

I followed this tutorial : https://docs.couchbase.com/userprofile-couchbase-mobile/sync/userprofile/xamarin/userprofile_sync.html

I have installed couchbase server , I created a bucket named : userprofile , and a user and I have enabled the Application Access and Read Only Admin roles. also I installed sync gateway and I have configured it , here is my configuration .json file

{
"log": ["*"],
"databases": {
"userprofile": {
  "server": "http://127.0.0.1:8091",
  "bucket": "user-profile",
  "username": "Maria", 
  "password": "123456", 
  "enable_shared_bucket_access": true, 
  "import_docs": true,
  "num_index_replicas": 0, 
  "delta_sync" :{"enabled":true},
  "users": {
  "Maria": { "password": "123456"},
    "GUEST": { "disabled": false, "admin_channels": ["*"] }
  },
  "sync": `function (doc, oldDoc) {
    if (doc.sdk) {
      channel(doc.sdk);
    }
  }`
 }
}
}

and I used this command to configure the sync gateway :

C:\Program Files\Couchbase\Sync Gateway\sync_gateway sync-gateway-config-userprofile-walrus.json

also I have changed the sync url to ws://10.0.2.2:4984 because I am using android emulator . but it did not sync between devices , can anyone help me please ?


Solution

  • 1) How are you verifying if the sync is working (what steps did you follow for testing)? If you are following the instructions here, that won't work with the config you have above. Because the only valid user that you have configured in your config file is the one with credentials "username" and "password" and the steps in tutorial indicates a different username/password. So make sure you log into your app with the credentials you have in your config file and try out

    2) You indicated that you have a Couchbase Server running that you have configured for Sync Gateway access. But your config file indicates that you are using "walrus" mode (Walrus mode is a memory only mode intended only for dev/test purposes). In other words, in walrus mode, you are not pointing to an actual couchbase server.

    If you want to sync with a backend Couchbase Server(which you should), then replace the "walrus:" in the "server" property in the config file to point to the couchbase server.

    3) The best resource to troubleshoot is the Sync Gateway logs. That should give sufficient hints as to what is going wrong with the sync. Post the errors you are seeing if any if the above tips don't work

    4) Check out this tutorial for relevant background. Probably from this point