Sync with Couchbase Lite through Couchbase Sync Gateway doesn’t see any documents (Channel issue?)


[The same question but with better formatting is available here: ]

I’m trying to sync a Couchbase bucket from the server to an iOS app using the Couchbase Sync Gateway and Couchbase Lite for iOS.

So far I’m working with the “beer-sample” example bucket that comes with Couchbase.

On my Ubuntu 12.04 LTS VM, the Couchbase Sync Gateway is started with this config file:

         "sync":`function(doc) {channel(["public"]);}`,
         "users": {
             "GUEST": {"disabled": false, "admin_channels": ["public"]}

My intention is to get it running without worrying about authentication first, therefore the GUEST user.

I’ve also modified some example to make sure the channel assignment is not dependent on the documents, because the sample bucket doesn’t have any channel assignment:

"sync":`function(doc) {channel(["public"]);}`,

I included some code from into my own example project, and after a bit of trying the iOS can actually connect to the connector.

The NSLog in line 168 gives me this output:

[1026:60b] SYNCMGR: active=0; status=1; 0/0; (null)
[1026:60b] SYNCMGR: active=1; status=3; 0/0; (null)
[1026:60b] SYNCMGR: active=0; status=2; 0/0; (null)

…and my interpretation of that is that the syncing (of 0 documents) was working successfully.

Why does the Couchbase Sync Gateway not report any documents to the Couchbase Lite? I’m obviously missing something. I suspect the channels are not setup correctly.

Any help will be appreciated.


Based on your description of the issue and configuration, you still need to configure your Sync Gateway to let it know there is an existing Couchbase Server bucket it needs to sync from.

This is a recent feature add after our Beta 2; we’re currently working on the documentation, which is available interim here:


The gateway has its own schema for storing documents in buckets and it’s not really designed to work with a pre-existing bucket you’ve already put data into.

If you just want to get this up and running easily, you can set the “importDocs” property to true in the database configuration object in the JSON config file. This tells the gateway there might be unversioned foreign documents in its bucket at startup, and it’ll scan through and add versioning metadata to them when it starts up.

The real way to support this, especially if you ever need to work with that bucket using Couchbase APIs (to read or write docs), is to use “bucket shadowing”. I believe the gateway docs cover this. You create a new empty bucket for the gateway to use, but point to your existing “beer” bucket and tell it to shadow that.