0

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 ?

Maria Nabil
  • 139
  • 1
  • 10

1 Answers1

1

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

rajagp
  • 1,443
  • 8
  • 10
  • Thank you so much , I have updated the config file as it is in the question now , but still the Sync Gateway is not connecting to Couchbase Server cluster instead it is connecting to local database (walrus) , I found this from the logs and I don't know why it is not connecting now . – Maria Nabil Dec 17 '19 at 14:13
  • Do you want to connect to walrus or server ? The config you have connects the sync gateway to couchbase server on localhost on port 8091. So it is working as expected. Is there a reason you want to use walrus mode when you have a running Couchbase Server? The walrus mode is not a "true" server replacement- Its a memory only store meant only for dev/demos to simplify the setup (so you don't have to setup a server) – rajagp Dec 17 '19 at 23:52
  • No I want to run on the server not on walrus mode , but I am still having the problem that the server is not syncing withe the mobile and I don't know why and how to solve it . – Maria Nabil Dec 19 '19 at 09:05