Can't reproduce simple example from tutorial with Sync Gateway :(

Hi guys!
Just checking out Couchbase, so I’m kinda stuck with tutorials:

  1. VS2012 => Simple app from tutorial
  2. Sync Gateway installed in Walrus mode.
  3. No users and passwords, just GUEST.
  4. I’ ve run app: create a db, a simple record and expect to synchro with Sync Gateway.

Then nothing happens. I mean, should I see this simple record when I opened db admin url and check it contents? If I manually create a a doc from admin session and save it I can see it only in db admin url section but no sychronization with my app happen either.

Am I misssing something?

Is the the document you created have a field called:

{
....
"channels":["water"]
...
}

Check this youtube video out to learn more about how sync gateway works:

The default sync looks like this

function(doc){
channel(doc.channels)
}

So I guess you have to have “channels” field. But, I did:

  1. .NET tutotrial
  2. Install Sync Gateway

The sync-gateway-config.json already contains sync function:

function (doc, oldDoc) {
if (doc.sdk) {
channel(doc.sdk);
}
}

And channel should be selected from “sdk” field?

@Cyb

in the sync gateway logs.

Could you copy and paste your sync gateway logs when you try to connect to it.

@househippo

2018-01-26T11:11:37.260+06:00 Enabling logging: [HTTP+]
2018-01-26T11:11:37.279+06:00 ==== Couchbase Sync Gateway/1.5.1(4;cb9522c) ====
2018-01-26T11:11:37.279+06:00 Opening db /hello as bucket “hello”, pool “default”, server walrus:
2018-01-26T11:11:37.280+06:00 Opening Walrus database hello on walrus:
2018-01-26T11:11:37.281+06:00 Reset guest user to config
2018-01-26T11:11:37.281+06:00 Starting admin server on 127.0.0.1:4985
2018-01-26T11:11:37.285+06:00 Starting server on 127.0.0.1:4984 …
2018-01-26T11:11:51.471+06:00 HTTP: #001: GET /hello/_changes?feed=websocket
2018-01-26T11:11:51.471+06:00 HTTP+: #001: → 101 Upgraded to WebSocket protocol (0.0 ms)

@Cyb,

Could you put on full logging. The logs don’t have the information about what data was sent to you only that you asked for changes.

"log":["*"]

2018-01-26T13:03:25.959+06:00 Enabling logging: []
2018-01-26T13:03:25.994+06:00 ==== Couchbase Sync Gateway/1.5.1(4;cb9522c) ====
2018-01-26T13:03:25.994+06:00 Opening db /hello as bucket “hello”, pool “default”, server walrus:
2018-01-26T13:03:25.994+06:00 Opening Walrus database hello on walrus:
2018-01-26T13:03:25.995+06:00 Cache: Initializing changes cache with options {Ch
annelCacheOptions:{ChannelCacheMinLength:0 ChannelCacheMaxLength:0 ChannelCacheA
ge:0s} CachePendingSeqMaxWait:5s CachePendingSeqMaxNum:10000 CacheSkippedSeqMaxW
ait:1h0m0s}
2018-01-26T13:03:25.995+06:00 Feed: Starting mutation feed on bucket hello due t
o either channel cache mode or doc tracking (auto-import/bucketshadow)
2018-01-26T13:03:25.995+06:00 Auth: Saved sync:user:: &{{ *:1 %!s(uint64=1) %
!s(*uint16=)} { %!s(bool=false) []} %!s(*auth.Authenticator=&{0xc0
4221afc0 0xc0421db400}) []}
2018-01-26T13:03:25.995+06:00 Changes+: Notifying that “hello” changed (keys="{

sync:user:}") count=2
2018-01-26T13:03:25.995+06:00 Reset guest user to config
2018-01-26T13:03:25.995+06:00 Cache: Received #1 ("_user/")
2018-01-26T13:03:25.995+06:00 Starting admin server on 127.0.0.1:4985
2018-01-26T13:03:25.996+06:00 Cache: Initialized cache for channel "
" with opti
ons: &{ChannelCacheMinLength:50 ChannelCacheMaxLength:500 ChannelCacheAge:1m0s}
2018-01-26T13:03:25.996+06:00 Cache: #1 ==> channel “
2018-01-26T13:03:25.997+06:00 Changes+: Notifying that “hello” changed (keys=”{

}”) count=3
2018-01-26T13:03:25.999+06:00 Starting server on 127.0.0.1:4984 …
2018-01-26 13:03:41.673067 I | SG-Bucket: … view returned 0 rows
2018-01-26T13:03:41.673+06:00 Access: Computed channels for “”: !:1,:1
2018-01-26 13:03:41.757072 I | SG-Bucket: … view returned 0 rows
2018-01-26T13:03:41.757+06:00 Access: Computed roles for “”:
2018-01-26T13:03:41.758+06:00 HTTP: #001: GET /hello/changes?feed=websocket
2018-01-26T13:03:41.758+06:00 Changes+: Notifying that “hello” changed (keys="{

sync:user:}") count=4
2018-01-26T13:03:41.758+06:00 Cache: Received #1 ("_user/")
2018-01-26T13:03:41.758+06:00 HTTP+: #001: --> 101 Upgraded to WebSocket pro
tocol (0.0 ms)
2018-01-26T13:03:41.758+06:00 Cache+: Ignoring duplicate of #1
2018-01-26T13:03:41.780+06:00 Changes+: Int sequence multi changes feed…
2018-01-26T13:03:41.780+06:00 Changes: MultiChangesFeed(channels: {
}, options:
{Since:0 Limit:0 Conflicts:true IncludeDocs:false Wait:true Continuous:true Term
inator:0xc042d748a0 HeartbeatMs:300000 TimeoutMs:300000 ActiveOnly:false}) …
2018-01-26T13:03:41.780+06:00 Changes+: MultiChangesFeed: channels expand to “!:
1,:1" …
2018-01-26T13:03:41.780+06:00 Cache: Initialized cache for channel “!” with opti
ons: &{ChannelCacheMinLength:50 ChannelCacheMaxLength:500 ChannelCacheAge:1m0s}
2018-01-26T13:03:41.780+06:00 Cache: getCachedChanges("!", 0) --> 0 changes valid from #1
2018-01-26T13:03:41.781+06:00 Changes+: [changesFeed] Found 0 changes for channel !
2018-01-26T13:03:41.781+06:00 Cache: getCachedChanges("
”, 0) --> 1 changes valid from #1
2018-01-26T13:03:41.781+06:00 Changes+: [changesFeed] Found 1 changes for channel *
2018-01-26T13:03:41.781+06:00 Changes+: Channel feed processing seq:1 in channel *
2018-01-26T13:03:41.781+06:00 Changes+: MultiChangesFeed sending {Seq:1, ID:_use
r/, Changes:[map[rev:]]}
2018-01-26T13:03:41.781+06:00 Changes+: MultiChangesFeed waiting…
2018-01-26T13:03:41.781+06:00 Changes: sending 1 change(s)
2018-01-26T13:03:41.781+06:00 Changes+: No new changes to send to change listener. Waiting for “hello”'s count to pass 4

Looks like the Guest user does not have access to any channels except the global public channel “!”

the logs you pasted in the forum for the _changes feed was cut short , but for the most part since there are no documents on the “!” channel and I’m guessing the Guest user only has access to the “!” he is not getting any data.

EXAMPLE in this config.json the Guest user has access to

"admin_channels":["*"]

to All the channels.

https://github.com/couchbase/sync_gateway/blob/master/examples/basic-walrus-bucket.json

2018-01-26T13:30:55.309+06:00 ==== Couchbase Sync Gateway/1.5.1(4;cb9522c) ====
2018-01-26T13:30:55.309+06:00 Opening db /hello as bucket “hello”, pool “default”, server walrus:
2018-01-26T13:30:55.309+06:00 Opening Walrus database hello on walrus:
2018-01-26T13:30:55.310+06:00 Cache: Initializing changes cache with options {ChannelCacheOptions:{ChannelCacheMinLength:0 ChannelCacheMaxLength:0 ChannelCacheAge:0s} CachePendingSeqMaxWait:5s CachePendingSeqMaxNum:10000 CacheSkippedSeqMaxWait:1h0m0s}
2018-01-26T13:30:55.310+06:00 Feed: Starting mutation feed on bucket hello due to either channel cache mode or doc tracking (auto-import/bucketshadow)
2018-01-26T13:30:55.310+06:00 Using default sync function ‘channel(doc.channels)’ for database “hello”
2018-01-26T13:30:55.310+06:00 Changes+: Notifying that “hello” changed (keys=“{_sync:user:}”) count=2
2018-01-26T13:30:55.310+06:00 Auth: Saved _sync:user:: &{{ :1 %!s(uint64=1) %!s(uint16=)} { %!s(bool=false) []} %!s(auth.Authenticator=&{0xc04221b000 0xc0421dd400}) []}
2018-01-26T13:30:55.310+06:00 Cache: Received #1 (“_user/”)
2018-01-26T13:30:55.311+06:00 Reset guest user to config
2018-01-26T13:30:55.311+06:00 Cache: Initialized cache for channel "
" with options: &{ChannelCacheMinLength:50 ChannelCacheMaxLength:500 ChannelCacheAge:1m0s}
2018-01-26T13:30:55.311+06:00 Starting admin server on 127.0.0.1:4985
2018-01-26T13:30:55.311+06:00 Cache: #1 ==> channel "
"
2018-01-26T13:30:55.311+06:00 Changes+: Notifying that “hello” changed (keys="{
}") count=3
2018-01-26T13:30:55.315+06:00 Starting server on :4984 …
2018-01-26 13:31:11.724268 I | SG-Bucket: … view returned 0 rows
2018-01-26T13:31:11.724+06:00 Access: Computed channels for “”: !:1,:1
2018-01-26 13:31:11.793272 I | SG-Bucket: … view returned 0 rows
2018-01-26T13:31:11.793+06:00 Access: Computed roles for “”:
2018-01-26T13:31:11.794+06:00 HTTP: #001: GET /hello/_changes?feed=websocket
2018-01-26T13:31:11.794+06:00 Changes+: Notifying that “hello” changed (keys=“{_sync:user:}”) count=4
2018-01-26T13:31:11.794+06:00 Cache: Received #1 (“_user/”)
2018-01-26T13:31:11.794+06:00 HTTP+: #001: → 101 Upgraded to WebSocket protocol (0.0 ms)
2018-01-26T13:31:11.794+06:00 Cache+: Ignoring duplicate of #1
2018-01-26T13:31:11.815+06:00 Changes+: Int sequence multi changes feed…
2018-01-26T13:31:11.815+06:00 Changes: MultiChangesFeed(channels: {
}, options: {Since:0 Limit:0 Conflicts:true IncludeDocs:false Wait:true Continuous:true Terminator:0xc042d296e0 HeartbeatMs:300000 TimeoutMs:300000 ActiveOnly:false}) …
2018-01-26T13:31:11.816+06:00 Changes+: MultiChangesFeed: channels expand to “!:1,:1" …
2018-01-26T13:31:11.816+06:00 Cache: Initialized cache for channel “!” with options: &{ChannelCacheMinLength:50 ChannelCacheMaxLength:500 ChannelCacheAge:1m0s}
2018-01-26T13:31:11.817+06:00 Cache: getCachedChanges(“!”, 0) → 0 changes valid from #1
2018-01-26T13:31:11.818+06:00 Changes+: [changesFeed] Found 0 changes for channel !
2018-01-26T13:31:11.818+06:00 Cache: getCachedChanges("
”, 0) → 1 changes valid from #1
2018-01-26T13:31:11.819+06:00 Changes+: [changesFeed] Found 1 changes for channel *
2018-01-26T13:31:11.819+06:00 Changes+: Channel feed processing seq:1 in channel *
2018-01-26T13:31:11.820+06:00 Changes+: MultiChangesFeed sending {Seq:1, ID:_user/, Changes:[map[rev:]]}
2018-01-26T13:31:11.820+06:00 Changes+: MultiChangesFeed waiting…
2018-01-26T13:31:11.820+06:00 Changes: sending 1 change(s)
2018-01-26T13:31:11.821+06:00 Changes+: No new changes to send to change listener. Waiting for “hello”'s count to pass 4

This is log using your json settings file.

The walrus DB is a memory only DB so every time you restart SG all the documents is gone.

So it looks like you start SG with no data
and then the first command you to do is ask for data but there is no data to give.

  1. Yep, I know.
  2. I was expecting that my app synchronize data with SG instead.

Do you mean that data should be pushed from your device to SG?.

Do you have the correct url in CBL.
It should be htttp://127.0.0.1:4984/db

Please share the replicator code that you have in your App.

  1. As far as I understand the tutorial, data should be being pushed to and pulled from http://localhost:4984/_DB_NAME
  2. Yes, I have correct CBL
  3. So far I can not nor push nor pull data from SG with those information from tutorials :frowning:

The whole code is taken from here

        // Create replicators to push & pull changes to & from Sync Gateway.
        Uri url = new Uri("http://127.0.0.1:4984/hello/");
        push = database.CreatePushReplication(url);
        pull = database.CreatePullReplication(url);
        push.Continuous = true;
        pull.Continuous = true;

        // Start replicators
        push.Start();
        pull.Start();

Sorry if you had mentioned this earlier, what version of the .Net CBL are you using ? And did you confirm through the CBL console logs that the document was successfully persisted in the local database (can you share the Couchbase Lite logs)

Couchbase.Lite 1.4.1
Couchbase.Lite.Storage.SystemSQLite 1.4.1

Where I can find CBL logs? Created document stored for sure, I can run app again and retrieve it, also total document count = 1 :slight_smile:

ps: Win7 64 Ult, VS2012

I’m not so familiar with .NET, but I expcet http://localhost:4984/_DB_NAME is your problem. Your mobile device (or emulator) is probably trying to connect to itself, not your Windows machine. Are you testing on an emulator, or device?

If an emulator, I believe you’ll need to look up the substitute IP. For example, the Android standard emulator automatically forwards connections to 10.0.2.2 to the host machine’s localhost. Other emulators/simulators have similar hooks.

If you’re running on a device, you’d need to have SG listen on an external interface and use the appropriate IP for that.

You can also test some things out on the command line. This blog and related ones might help.

Actually, on further checking, the iOS simulator does forward localhost. What are you testing on?

Ok, let me clear off some things:

  1. I am testing SG on the desktop, Win7 64 Ult, tried on Win10 Ent - the same thing.
  2. At first I used VS2012, then move to VS2015 - the same thing.
  3. My client app and SG are on the same machine.
  4. Now, when i check out debug outputs there are always same errors:

Exception thrown: ‘Couchbase.Lite.HttpResponseException’ in Couchbase.Lite.dll
Exception thrown: ‘System.AggregateException’ in Couchbase.Lite.dll
WARN) SYNC (RemoteSession): [14] 2018-1-27 11:51:01.800+06:00 Http Message failed to send, or got error response, passing to callback… http://127.0.0.1:4984/hello/_revs_diff, :
—> System.AggregateException:
—> Couchbase.Lite.HttpResponseException:
“Couchbase.Lite.HttpResponseException”.
Couchbase.Lite.Util.TransientErrorRetryHandler.HandleTransientErrors(Task1 request, Object state) Couchbase.Lite.Util.TransientErrorRetryHandler.<>c__DisplayClass4_0.<ResendHandler>b__0(Task1 t)
System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() System.Threading.Tasks.Task.Execute() Couchbase.Lite.CouchbaseLiteHttpClient.<SendAsync>b__13_2(Task1 t)
System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() System.Threading.Tasks.Task.Execute() ---> (Inner exception #0) System.AggregateException: ---> Couchbase.Lite.HttpResponseException: "Couchbase.Lite.HttpResponseException". Couchbase.Lite.Util.TransientErrorRetryHandler.HandleTransientErrors(Task1 request, Object state)
Couchbase.Lite.Util.TransientErrorRetryHandler.<>c__DisplayClass4_0.b__0(Task1 t) System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke()
System.Threading.Tasks.Task.Execute()
Couchbase.Lite.CouchbaseLiteHttpClient.b__13_2(Task1 t) System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke()
System.Threading.Tasks.Task.Execute()
—> (Inner exception #0) [HttpResponseException: StatusCode = BadRequest]<—
<—
WARN) SYNC (RemoteSession): [14] 2018-1-27 11:51:01.801+06:00 Failed content:
INFO) SYNC (Replication): [6] 2018-1-27 11:51:01.803+06:00 Error set during replication (application may continue):
[HttpResponseException: StatusCode = BadRequest]