Not able to connect Sync Gateway with Couchbase server

Hi there,

I am new to Couchbase and Sync gateway and am following this guide to connect my sync gateway with Couchbase Server but I am not able to see the documents on my sync gateway being pulled on the Couchbase server.
I have followed the exact steps mentioned in the above link but am not sure where I am wrong.

@Mayuri, is it possible to provide sg_info log? If not possible, can you provide errors or any logs on sync gateway.

The reason for not seeing documents to your sync gateway is if you do not enable “enable_shared_bucket_access”: true in your sync gateway config and make sure “import_docs” is not disabled on your sync gateway config

This is my serviceconfig.json of sync gateway. I am not sure whether this is the file which I should change. Initially I had made a ‘sync-gateway-config.json’ file inside examples folder with the same configuration but couldn’t get any result.

{
“adminInterface”: “127.0.0.1:4985”,
“interface”: “0.0.0.0:4984”,
“databases”: {
“grocery-sync”: {
“server”: “walrus:data”,
“server”: “http://localhost:8091”,
“bucket”: “grocery-sync”,
“username”: “username”,
“password”: “password”,
“enable_shared_bucket_access”: true,
“import_docs”: true,
“num_index_replicas”: 0,
“users”: {
“GUEST”: {“disabled”: false, “admin_channels”: ["*"] }
},
“allow_conflicts”: false,
“revs_limit”: 20
}
}
}

This is screenshot of couchbase server where I am getting some entries which are not as those on sync gateway. I am not sure where they are coming from

this is the sg_info.log.

2020-10-01T22:31:23.325+05:30 [INF] GoCBCustomSGTranscoder Opening Couchbase database grocery-sync on
2020-10-01T22:31:23.325+05:30 [INF] Auth: Attempting credential authentication localhost:8091?http_idle_conn_timeout=90000&http_max_idle_conns=64000&http_max_idle_conns_per_host=256&kv_pool_size=2&n1ql_timeout=75000&operation_tracing=false
2020-10-01T22:31:27.936+05:30 [INF] Error opening bucket grocery-sync: failed to connect to any of the specified hosts
2020-10-01T22:31:27.936+05:30 [WRN] RetryLoop for Attempt to connect to bucket : grocery-sync giving up after 14 attempts – base.RetryLoop() at util.go:382
2020-10-01T22:31:27.936+05:30 [ERR] Error opening database grocery-sync: 502 Unable to connect to Couchbase Server (connection refused). Please ensure it is running and reachable at the configured host and port. Detailed error: failed to connect to any of the specified hosts – rest.RunServer() at config.go:1028
2020-10-03T08:45:45.503+05:30 ==== Couchbase Sync Gateway/2.7.3(3;33d352f) CE ====
2020-10-03T08:45:45.423+05:30 ==== Couchbase Sync Gateway/2.7.3(3;33d352f) CE ====
2020-10-03T08:45:45.601+05:30 [INF] Logging: Console disabled
2020-10-03T08:45:45.601+05:30 [INF] Logging: Files to C:\Program Files\Couchbase\Sync Gateway\var\lib\couchbase\logs
2020-10-03T08:45:45.601+05:30 [INF] Logging: Console level: none
2020-10-03T08:45:45.601+05:30 [INF] Logging: Console keys: [HTTP]
2020-10-03T08:45:45.601+05:30 [INF] Logging: Redaction level: none
2020-10-03T08:45:45.601+05:30 [INF] Logging stats with frequency: 1m0s
2020-10-03T08:45:45.601+05:30 [INF] Opening db /grocery-sync as bucket “grocery-sync”, pool “default”, server ocalhost:8091>
2020-10-03T08:45:45.602+05:30 [INF] GoCBCustomSGTranscoder Opening Couchbase database grocery-sync on ocalhost:8091> as user “username”
2020-10-03T08:45:45.829+05:30 [INF] Auth: Attempting credential authentication localhost:8091?http_idle_conn_timeout=90000&http_max_idle_conns=64000&http_max_idle_conns_per_host=256&kv_pool_size=2&n1ql_timeout=75000&operation_tracing=false
2020-10-03T08:45:47.459+05:30 [INF] Successfully opened bucket grocery-sync
2020-10-03T08:45:48.311+05:30 [INF] Set query timeouts for bucket grocery-sync to cluster:1m15s, bucket:1m15s
2020-10-03T08:45:48.325+05:30 [INF] Initializing indexes with numReplicas: 0…
2020-10-03T08:45:48.797+05:30 [INF] Verifying index availability for bucket grocery-sync…
2020-10-03T08:45:49.796+05:30 [INF] Indexes ready for bucket grocery-sync.
2020-10-03T08:45:49.938+05:30 [INF] delta_sync enabled=false with rev_max_age_seconds=86400 for database grocery-sync
2020-10-03T08:45:49.995+05:30 [INF] Created background task: “CleanAgedItems” with interval 1m0s
2020-10-03T08:45:49.995+05:30 [INF] Cache: Initializing changes cache for database grocery-sync with options {ChannelCacheOptions:{ChannelCacheMinLength:50 ChannelCacheMaxLength:500 ChannelCacheAge:1m0s MaxNumChannels:50000 CompactHighWatermarkPercent:80 CompactLowWatermarkPercent:60} CachePendingSeqMaxWait:5s CachePendingSeqMaxNum:10000 CacheSkippedSeqMaxWait:1h0m0s}
2020-10-03T08:45:49.995+05:30 [INF] Created background task: “InsertPendingEntries” with interval 2.5s
2020-10-03T08:45:49.995+05:30 [INF] Created background task: “CleanSkippedSequenceQueue” with interval 30m0s
2020-10-03T08:45:49.996+05:30 [INF] DCP: Attempting to start import DCP feed…
2020-10-03T08:45:50.116+05:30 [INF] DCP: Registering PindexImplType for syncGateway-import-grocery-sync
2020-10-03T08:45:50.116+05:30 [INF] DCP: Starting DCP import feed for bucket: “grocery-sync”
2020-10-03T08:45:50.867+05:30 [INF] DCP: Previously persisted backfill sequences found - will resume
CP: c:grocery-sync-SGI Restarting vb 1016 using metadata sequence 0 (backfill 0 not in [0-0])
2020-10-03T08:45:51.079+05:30 [INF] DCP: c:grocery-sync-SGI Restarting vb 1017 using metadata sequence 0 (backfill 0 not in [0-0])
2020-10-03T08:45:51.079+05:30 [INF] DCP: c:grocery-sync-SGI Restarting vb 1018 using metadata sequence 0 (backfill 0 not in [0-0])
2020-10-03T08:45:51.079+05:30 [INF] DCP: c:grocery-sync-SGI Restarting vb 1019 using metadata sequence 0 (backfill 0 not in [0-0])
2020-10-03T08:45:51.079+05:30 [INF] DCP: c:grocery-sync-SGI Restarting vb 1020 using metadata sequence 0 (backfill 0 not in [0-0])
2020-10-03T08:45:51.079+05:30 [INF] DCP: c:grocery-sync-SGI Restarting vb 1021 using metadata sequence 0 (backfill 0 not in [0-0])
2020-10-03T08:45:51.079+05:30 [INF] DCP: c:grocery-sync-SGI Restarting vb 1022 using metadata sequence 0 (backfill 0 not in [0-0])
2020-10-03T08:45:51.079+05:30 [INF] DCP: c:grocery-sync-SGI Restarting vb 1023 using metadata sequence 0 (backfill 0 not in [0-0])
2020-10-03T08:45:51.198+05:30 [INF] DCP: c:grocery-sync-SGI DCP feed starting with name SGI-v-2.7-commit–uuid-bd87ca57-0526-11eb-bbbd-180373c77920
2020-10-03T08:45:51.226+05:30 [INF] DCP: Starting mutation feed on bucket grocery-sync due to either channel cache mode or doc tracking (auto-import)
2020-10-03T08:45:51.226+05:30 [INF] DCP: Using DCP feed for bucket: “grocery-sync” (based on feed_type specified in config file)
2020-10-03T08:45:51.445+05:30 [INF] DCP: c:grocery-sync-SG DCP feed starting with name SG-v-2.7-commit–uuid-bdb31a35-0526-11eb-bbbd-180373c77920
2020-10-03T08:45:51.769+05:30 [INF] Using metadata purge interval of 3.00 days for tombstone compaction.
2020-10-03T08:45:51.772+05:30 [INF] Created background task: “Compact” with interval 24h0m0s
2020-10-03T08:45:51.782+05:30 [INF] Using default sync function ‘channel(doc.channels)’ for database “grocery-sync”
2020-10-03T08:45:51.833+05:30 [INF] Reset guest user to config
2020-10-03T08:45:51.873+05:30 [INF] Starting admin server on 127.0.0.1:4985
2020-10-03T08:45:52.085+05:30 [INF] CBGoUtilsLogger: Using plain authentication for user username
2020-10-03T08:45:52.085+05:30 [INF] CBGoUtilsLogger: Using plain authentication for user username
2020-10-03T08:45:52.143+05:30 [INF] Starting server on 0.0.0.0:4984 …
2020-10-03T08:45:54.741+05:30 [INF] HTTP: #001: GET /favicon.ico/ (as ADMIN)
2020-10-03T08:45:54.741+05:30 [INF] HTTP: #001: --> 400 invalid database name “favicon.ico” (10.0 ms)
2020-10-03T08:45:55.315+05:30 [INF] HTTP: #002: GET /_all_dbs (as ADMIN)
2020-10-03T08:45:55.323+05:30 [INF] HTTP+: #002: --> 200 (8.0 ms)
2020-10-03T08:45:55.450+05:30 [INF] HTTP: #003: GET /favicon.ico/ (as ADMIN)
2020-10-03T08:45:55.450+05:30 [INF] HTTP: #003: --> 400 invalid database name “favicon.ico” (0.0 ms)
2020-10-03T08:45:57.587+05:30 [INF] HTTP: #004: GET /grocery-sync/_config (as ADMIN)
2020-10-03T08:45:57.606+05:30 [INF] HTTP+: #004: --> 200 (19.0 ms)
2020-10-03T08:45:57.620+05:30 [INF] HTTP: #006: GET /grocery-sync/_changes?limit=10&include_docs=true (as ADMIN)
2020-10-03T08:45:57.602+05:30 [INF] HTTP: #005: GET /favicon.ico/ (as ADMIN)
2020-10-03T08:45:57.802+05:30 [INF] HTTP: #005: --> 400 invalid database name “favicon.ico” (200.0 ms)
2020-10-03T08:45:57.812+05:30 [INF] Changes: c:#006 MultiChangesFeed(channels: {}, options: {Since: 0, Limit: 10, Conflicts: false, IncludeDocs: true, Wait: false, Continuous: false, HeartbeatMs: 0, TimeoutMs: 300000, ActiveOnly: false}) …
2020-10-03T08:45:58.114+05:30 [INF] Cache: Querying ‘channels’ for "
" (start=#1, end=#2, limit=10)
2020-10-03T08:45:58.125+05:30 [INF] Cache: Got no rows from query for channel:""
2020-10-03T08:45:58.125+05:30 [INF] Cache: GetChangesInChannel("
") --> 0 rows
2020-10-03T08:45:58.126+05:30 [INF] Changes: c:#006 MultiChangesFeed done
2020-10-03T08:45:58.126+05:30 [INF] HTTP+: #006: --> 200 OK (505.9 ms)
2020-10-03T08:45:58.131+05:30 [INF] HTTP: #007: GET /grocery-sync/_changes?since=0&include_docs=true&limit=10 (as ADMIN)
2020-10-03T08:45:58.131+05:30 [INF] Changes: c:#007 MultiChangesFeed(channels: {}, options: {Since: 0, Limit: 10, Conflicts: false, IncludeDocs: true, Wait: false, Continuous: false, HeartbeatMs: 0, TimeoutMs: 300000, ActiveOnly: false}) …
2020-10-03T08:45:58.131+05:30 [INF] Changes: c:#007 MultiChangesFeed done
2020-10-03T08:45:58.131+05:30 [INF] HTTP+: #007: --> 200 OK (0.0 ms)
2020-10-03T08:45:58.133+05:30 [INF] HTTP: #008: GET /grocery-sync/_changes?since=0&include_docs=true&feed=longpoll (as ADMIN)
2020-10-03T08:45:58.133+05:30 [INF] Changes: c:#008 MultiChangesFeed(channels: {
}, options: {Since: 0, Limit: 0, Conflicts: false, IncludeDocs: true, Wait: true, Continuous: false, HeartbeatMs: 0, TimeoutMs: 300000, ActiveOnly: false}) …
2020-10-03T08:45:58.329+05:30 [INF] HTTP: #009: GET /grocery-sync/_all_docs (as ADMIN)
2020-10-03T08:45:58.369+05:30 [INF] HTTP+: #009: --> 200 OK (40.0 ms)
2020-10-03T08:45:59.595+05:30 [INF] Changes: c:#008 Connection lost from client
2020-10-03T08:45:59.595+05:30 [INF] HTTP+: #008: --> 200 OK (0.0 ms)
2020-10-03T08:45:59.693+05:30 [INF] HTTP: #010: GET /favicon.ico/ (as ADMIN)
2020-10-03T08:45:59.693+05:30 [INF] HTTP: #010: --> 400 invalid database name “favicon.ico” (0.0 ms)
2020-10-03T08:46:00.074+05:30 [INF] HTTP: #011: GET /_all_dbs (as ADMIN)
2020-10-03T08:46:00.074+05:30 [INF] HTTP+: #011: --> 200 (0.0 ms)
2020-10-03T08:46:00.121+05:30 [INF] HTTP: #012: GET /favicon.ico/ (as ADMIN)
2020-10-03T08:46:00.121+05:30 [INF] HTTP: #012: --> 400 invalid database name “favicon.ico” (0.0 ms)
2020-10-03T08:46:01.525+05:30 [INF] HTTP: #013: GET /grocery-sync/_config (as ADMIN)
2020-10-03T08:46:01.525+05:30 [INF] HTTP+: #013: --> 200 (0.0 ms)
2020-10-03T08:46:01.539+05:30 [INF] HTTP: #014: GET /grocery-sync/_changes?limit=10&include_docs=true (as ADMIN)
2020-10-03T08:46:01.539+05:30 [INF] Changes: c:#014 MultiChangesFeed(channels: {}, options: {Since: 0, Limit: 10, Conflicts: false, IncludeDocs: true, Wait: false, Continuous: false, HeartbeatMs: 0, TimeoutMs: 300000, ActiveOnly: false}) …
2020-10-03T08:46:01.539+05:30 [INF] Changes: c:#014 MultiChangesFeed done
2020-10-03T08:46:01.539+05:30 [INF] HTTP+: #014: --> 200 OK (0.0 ms)
2020-10-03T08:46:01.543+05:30 [INF] HTTP: #015: GET /favicon.ico/ (as ADMIN)
2020-10-03T08:46:01.543+05:30 [INF] HTTP: #015: --> 400 invalid database name “favicon.ico” (0.0 ms)
2020-10-03T08:46:01.552+05:30 [INF] HTTP: #016: GET /grocery-sync/_changes?since=0&include_docs=true&feed=longpoll (as ADMIN)
2020-10-03T08:46:01.552+05:30 [INF] Changes: c:#016 MultiChangesFeed(channels: {
}, options: {Since: 0, Limit: 0, Conflicts: false, IncludeDocs: true, Wait: true, Continuous: false, HeartbeatMs: 0, TimeoutMs: 300000, ActiveOnly: false}) …
2020-10-03T08:46:01.572+05:30 [INF] HTTP: #017: GET /grocery-sync/_changes?since=0&include_docs=true&limit=10 (as ADMIN)
2020-10-03T08:46:01.572+05:30 [INF] Changes: c:#017 MultiChangesFeed(channels: {*}, options: {Since: 0, Limit: 10, Conflicts: false, IncludeDocs: true, Wait: false, Continuous: false, HeartbeatMs: 0, TimeoutMs: 300000, ActiveOnly: false}) …
2020-10-03T08:46:01.572+05:30 [INF] Changes: c:#017 MultiChangesFeed done
2020-10-03T08:46:01.572+05:30 [INF] HTTP+: #017: --> 200 OK (0.0 ms)
2020-10-03T08:46:01.574+05:30 [INF] HTTP: #018: GET /grocery-sync/_all_docs (as ADMIN)
2020-10-03T08:46:01.578+05:30 [INF] HTTP+: #018: --> 200 OK (4.0 ms)
2020-10-03T08:46:04.443+05:30 [INF] Changes: c:#016 Connection lost from client
2020-10-03T08:46:04.443+05:30 [INF] HTTP+: #016: --> 200 OK (0.0 ms)
2020-10-03T08:46:04.537+05:30 [INF] HTTP: #019: GET /favicon.ico/ (as ADMIN)
2020-10-03T08:46:04.537+05:30 [INF] HTTP: #019: --> 400 invalid database name “favicon.ico” (0.0 ms)
2020-10-03T08:46:04.802+05:30 [INF] HTTP: #020: GET /_all_dbs (as ADMIN)
2020-10-03T08:46:04.803+05:30 [INF] HTTP+: #020: --> 200 (1.0 ms)
2020-10-03T08:46:04.829+05:30 [INF] HTTP: #021: GET /favicon.ico/ (as ADMIN)
2020-10-03T08:46:04.829+05:30 [INF] HTTP: #021: --> 400 invalid database name “favicon.ico” (0.0 ms)

@Mayuri, the error in. your logs “[ERR] Error opening database grocery-sync: 502 Unable to connect to Couchbase Server (connection refused). Please ensure it is running and reachable at the configured host and port. Detailed error: failed to connect to any of the specified hosts – rest.RunServer() at config.go:1028”
indicates that it is not able to reach couchbase server. Did you set up couchbase server and sync gateway in same machine? If not , can you provide the ipadress of couchbase server on sync gateway. config for the this " “server”: “http://localhost:8091”," - replace localhost with coubhase server ip. Also remove “server”: “walrus:data”, from sync gateway config file

Make sure couchbase server is reachable from sync gateway node.

Also, can you make sure you created user on couchbase server under settings category? The username for the bucket used in sync gateway. config file is ‘username’ , so you need to create user in couchbase server with same name/password as what you have mentioned in sync gateway config

you should get info in the sync gateway logs that it has connected successfully to the couchbase server , then you can see docs created in sync gateway to the couchbase server. I suspect that user is not created in coucbbase server and that could be reason it could not connect successfully

The couchbase server and the sync gateway are running on the same machine.
What should I do to make sure that the couchbase server is reachable from sync gateway node?

I am able to see data now. I had 2 entries on my sync gateway (the first and the 2nd last one ) but here I can see additional entries as well which I am not sure of. Can you please guide me with what these are?

These are the logs in sg_info.log.

2020-10-04T07:56:25.846+05:30 [INF] DCP: c:grocery-sync-SGI DCP feed starting with name SGI-v-2.7-commit–uuid-007a38f5-05e9-11eb-a0b8-180373c77920
2020-10-04T07:56:25.846+05:30 [INF] DCP: Starting mutation feed on bucket grocery-sync due to either channel cache mode or doc tracking (auto-import)
2020-10-04T07:56:25.846+05:30 [INF] DCP: Using DCP feed for bucket: “grocery-sync” (based on feed_type specified in config file)
2020-10-04T07:56:25.866+05:30 [INF] CBGoUtilsLogger: Using plain authentication for user user
2020-10-04T07:56:25.912+05:30 [INF] DCP: c:grocery-sync-SG DCP feed starting with name SG-v-2.7-commit–uuid-00844976-05e9-11eb-a0b8-180373c77920
2020-10-04T07:56:25.924+05:30 [INF] Using metadata purge interval of 3.00 days for tombstone compaction.
2020-10-04T07:56:25.924+05:30 [INF] Created background task: “Compact” with interval 24h0m0s
2020-10-04T07:56:25.933+05:30 [INF] Using default sync function ‘channel(doc.channels)’ for database “grocery-sync”
2020-10-04T07:56:25.933+05:30 [INF] Reset guest user to config
2020-10-04T07:56:25.934+05:30 [INF] Starting admin server on 127.0.0.1:4985
2020-10-04T07:56:25.946+05:30 [INF] CBGoUtilsLogger: Using plain authentication for user user
2020-10-04T07:56:25.959+05:30 [INF] Starting server on 0.0.0.0:4984 …
2020-10-04T07:56:25.963+05:30 [ERR] Failed to start HTTP server on 0.0.0.0:4984: listen tcp 0.0.0.0:4984: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted. – rest.(ServerConfig).Serve() at config.go:990
2020-10-04T07:56:25.964+05:30 [ERR] Failed to start HTTP server on 127.0.0.1:4985: listen tcp 127.0.0.1:4985: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted. – rest.(ServerConfig).Serve() at config.go:990
2020-10-04T07:56:25.989+05:30 [INF] DCP: Backfill in progress: 1% (1 / 76)
2020-10-04T07:56:26.786+05:30 [INF] HTTP+: #323: --> 200 OK (timeout) (0.0 ms)
2020-10-04T07:56:26.791+05:30 [INF] HTTP: #324: GET /grocery-sync/_changes?since=22&include_docs=true&feed=longpoll (as ADMIN)
2020-10-04T07:56:26.791+05:30 [INF] Changes: c:#324 MultiChangesFeed(channels: {
}, options: {Since: 22, Limit: 0, Conflicts: false, IncludeDocs: true, Wait: true, Continuous: false, HeartbeatMs: 0, TimeoutMs: 300000, ActiveOnly: false}) …
2020-10-04T07:56:31.134+05:30 [INF] Changes: c:#324 Connection lost from client
2020-10-04T07:56:31.134+05:30 [INF] HTTP+: #324: --> 200 OK (0.0 ms)
2020-10-04T07:56:31.261+05:30 [INF] HTTP: #325: GET /grocery-sync/_config (as ADMIN)
2020-10-04T07:56:31.261+05:30 [INF] HTTP+: #325: --> 200 (0.0 ms)
2020-10-04T07:56:31.264+05:30 [INF] HTTP: #326: GET /grocery-sync/_raw/00e9a0aa-b40c-4838-ac3c-ca76f6d26178 (as ADMIN)
2020-10-04T07:56:31.265+05:30 [INF] HTTP+: #326: --> 200 (1.0 ms)
2020-10-04T07:56:31.272+05:30 [INF] HTTP: #327: GET /grocery-sync/_changes?limit=10&include_docs=true (as ADMIN)
2020-10-04T07:56:31.272+05:30 [INF] Changes: c:#327 MultiChangesFeed(channels: {
}, options: {Since: 0, Limit: 10, Conflicts: false, IncludeDocs: true, Wait: false, Continuous: false, HeartbeatMs: 0, TimeoutMs: 300000, ActiveOnly: false}) …
2020-10-04T07:56:31.272+05:30 [INF] Cache: GetCachedChanges("", 0) --> 10 changes valid from #1
2020-10-04T07:56:31.272+05:30 [INF] Changes: c:#327 MultiChangesFeed done
2020-10-04T07:56:31.273+05:30 [INF] HTTP+: #327: --> 200 OK (1.0 ms)
2020-10-04T07:56:31.332+05:30 [INF] HTTP: #328: GET /favicon.ico/ (as ADMIN)
2020-10-04T07:56:31.332+05:30 [INF] HTTP: #328: --> 400 invalid database name “favicon.ico” (0.0 ms)
2020-10-04T07:56:31.340+05:30 [INF] HTTP: #329: GET /grocery-sync/_all_docs (as ADMIN)
2020-10-04T07:56:31.358+05:30 [INF] HTTP+: #329: --> 200 OK (18.0 ms)
2020-10-04T07:56:31.360+05:30 [INF] HTTP: #330: GET /grocery-sync/_changes?since=11&include_docs=true&limit=10 (as ADMIN)
2020-10-04T07:56:31.360+05:30 [INF] Changes: c:#330 MultiChangesFeed(channels: {
}, options: {Since: 11, Limit: 10, Conflicts: false, IncludeDocs: true, Wait: false, Continuous: false, HeartbeatMs: 0, TimeoutMs: 300000, ActiveOnly: false}) …
2020-10-04T07:56:31.360+05:30 [INF] Cache: GetCachedChanges("", 11) --> 10 changes valid from #12
2020-10-04T07:56:31.360+05:30 [INF] Changes: c:#330 MultiChangesFeed done
2020-10-04T07:56:31.360+05:30 [INF] HTTP+: #330: --> 200 OK (0.0 ms)
2020-10-04T07:56:31.362+05:30 [INF] HTTP: #331: GET /grocery-sync/_changes?since=11&include_docs=true&feed=longpoll (as ADMIN)
2020-10-04T07:56:31.362+05:30 [INF] Changes: c:#331 MultiChangesFeed(channels: {
}, options: {Since: 11, Limit: 0, Conflicts: false, IncludeDocs: true, Wait: true, Continuous: false, HeartbeatMs: 0, TimeoutMs: 300000, ActiveOnly: false}) …
2020-10-04T07:56:31.363+05:30 [INF] Cache: GetCachedChanges("", 11) --> 11 changes valid from #12
2020-10-04T07:56:31.363+05:30 [INF] Changes: c:#331 MultiChangesFeed done
2020-10-04T07:56:31.364+05:30 [INF] HTTP+: #331: --> 200 OK (0.0 ms)
2020-10-04T07:56:31.368+05:30 [INF] HTTP: #332: GET /grocery-sync/_changes?since=21&include_docs=true&limit=10 (as ADMIN)
2020-10-04T07:56:31.368+05:30 [INF] Changes: c:#332 MultiChangesFeed(channels: {
}, options: {Since: 21, Limit: 10, Conflicts: false, IncludeDocs: true, Wait: false, Continuous: false, HeartbeatMs: 0, TimeoutMs: 300000, ActiveOnly: false}) …
2020-10-04T07:56:31.368+05:30 [INF] Cache: GetCachedChanges("", 21) --> 1 changes valid from #22
2020-10-04T07:56:31.368+05:30 [INF] Changes: c:#332 MultiChangesFeed done
2020-10-04T07:56:31.368+05:30 [INF] HTTP+: #332: --> 200 OK (0.0 ms)
2020-10-04T07:56:31.373+05:30 [INF] HTTP: #333: GET /grocery-sync/_changes?since=22&include_docs=true&feed=longpoll (as ADMIN)
2020-10-04T07:56:31.373+05:30 [INF] Changes: c:#333 MultiChangesFeed(channels: {
}, options: {Since: 22, Limit: 0, Conflicts: false, IncludeDocs: true, Wait: true, Continuous: false, HeartbeatMs: 0, TimeoutMs: 300000, ActiveOnly: false}) …
2020-10-04T07:56:31.561+05:30 [INF] HTTP: #334: GET /grocery-sync/_changes?since=22&include_docs=true&limit=10 (as ADMIN)
2020-10-04T07:56:31.562+05:30 [INF] Changes: c:#334 MultiChangesFeed(channels: {}, options: {Since: 22, Limit: 10, Conflicts: false, IncludeDocs: true, Wait: false, Continuous: false, HeartbeatMs: 0, TimeoutMs: 300000, ActiveOnly: false}) …
2020-10-04T07:56:31.562+05:30 [INF] Changes: c:#334 MultiChangesFeed done
2020-10-04T07:56:31.562+05:30 [INF] HTTP+: #334: --> 200 OK (1.0 ms)
2020-10-04T08:01:31.376+05:30 [INF] HTTP+: #333: --> 200 OK (timeout) (0.0 ms)
2020-10-04T08:01:31.381+05:30 [INF] HTTP: #335: GET /grocery-sync/_changes?since=22&include_docs=true&feed=longpoll (as ADMIN)
2020-10-04T08:01:31.381+05:30 [INF] Changes: c:#335 MultiChangesFeed(channels: {
}, options: {Since: 22, Limit: 0, Conflicts: false, IncludeDocs: true, Wait: true, Continuous: false, HeartbeatMs: 0, TimeoutMs: 300000, ActiveOnly: false}) …

In addition to this I have another question.
How often or when does sync gateway refresh and delete all it’s data?
and if an app updates a document and couchbase server also updates the same doocument at the same time then which one the server takes in case of this conflict?

Only when user requests that the data in bucket be removed or if the document TTL expires … Also, note that Sync Gateway does not persist any data … Couchbase server is the backing data store for Sync Gateway. So if data needs to be remove, a purge request needs to be explicitly made to the data in the bucket or the expiration must be set accordingly

Check out the documentation on the conflict resolution strategy

Thank you I will look into it.
I am also trying to implement peer to peer sync using this guide https://docs.couchbase.com/couchbase-lite/2.6/java.html#peer-to-peer-sync for android device but as I could see the methods do not have complete code mentioned in there. I am new to couchbase and therefore clueless as to how to implement this.

I also tried to clone and run the android app mentioned in this blog https://blog.couchbase.com/how-to-use-sync-gateway-and-peer-to-peer-sync-on-android/ with github link https://github.com/couchbaselabs/mini-hacks/tree/master/android-rating-app/android but am unable to run it.

It is giving me the following error in android studio.

10-07 11:38:01.976 4557-4557/? I/hbase.ratingap: Not late-enabling -Xcheck:jni (already on)
10-07 11:38:02.873 4557-4557/com.couchbase.ratingapp W/hbase.ratingap: Unexpected CPU variant for X86 using defaults: x86
10-07 11:38:03.967 4557-4557/com.couchbase.ratingapp I/hbase.ratingap: The ClassLoaderContext is a special shared library.
10-07 11:38:06.810 4557-4557/com.couchbase.ratingapp W/linker: Warning: library “/system/lib/libsqlite.so” ("/system/lib/libsqlite.so") needed or dlopened by “/data/app/com.couchbase.ratingapp-Du-U1cXX1H62AEKO-t9q7Q==/lib/x86/libcom_couchbase_touchdb_TDCollateJSON.so” is not accessible by namespace “classloader-namespace” and will not work when the app moves to API level 24 or later (https://android.googlesource.com/platform/bionic/+/master/private-api-enforced-for-api-level-24) (allowing for now because this app’s target API level is still 22)
10-07 11:38:06.822 4557-4557/com.couchbase.ratingapp W/hbase.ratingap: Accessing hidden field Landroid/database/sqlite/SQLiteDatabase;->mThreadSession:Ljava/lang/ThreadLocal; (light greylist, JNI)
10-07 11:38:06.823 4557-4557/com.couchbase.ratingapp W/hbase.ratingap: Accessing hidden field Landroid/database/sqlite/SQLiteSession;->mConnectionPool:Landroid/database/sqlite/SQLiteConnectionPool; (dark greylist, JNI)
10-07 11:38:06.823 4557-4557/com.couchbase.ratingapp W/hbase.ratingap: Accessing hidden field Landroid/database/sqlite/SQLiteConnectionPool;->mAvailablePrimaryConnection:Landroid/database/sqlite/SQLiteConnection; (dark greylist, JNI)
10-07 11:38:06.823 4557-4557/com.couchbase.ratingapp W/hbase.ratingap: Accessing hidden field Landroid/database/sqlite/SQLiteConnection;->mConnectionPtr:J (dark greylist, JNI)
10-07 11:38:06.823 4557-4557/com.couchbase.ratingapp V/TDCollateJSON: SQLite3 handle is -464342528
10-07 11:38:06.823 4557-4557/com.couchbase.ratingapp A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 4557 (hbase.ratingapp), pid 4557 (hbase.ratingapp)

I am not sure how to proceed with this peer to peer implementation. Please guide me.

That blog is for 1.x version of Couchbase lite which is unsupported so I would recommend not bothering with it.
P2P sync is an Enterprise level feature. So if this is of interest to you and your team , I can put you in touch with our pre-sales tech team who can assist you further.

Also, you may be interested in our upcoming free virtual developer conference. You can register here- https://connect.couchbase.com/sessions.

It’s coming up next week and we have a session on peer-to-peer which should offer a good starting point

Oh okay.
Is there any peer-leader concept as well 'cause I couldn’t find any documentation on it and just came across peer-peer sync. If yes, is that a part of Enterprise edition as well?

Also, I wanted to know if couchbase lite creates any database folder in mobile wherein it stores data locally? If yes, what is the path that I can use to reach it through my mobile.

I would like if you could get me and my team in touch with the pre-sales team for further assistance.
Also, I am based in India and the conference is not in IST so will there be recordings available for the same?

Yes- This is part of Enterprise Edition. Our latest release of CBL 2.8 with our latest peer to peer functionality is available - You can download and test it for free.

The recordings as available on demand. Hope you are able to watch them. If this meets your needs , let me know and I will put you in contact with relevant folks from our pre-sales teams who can help you.

https://connectonline.influitive.com/forum/t/peer-to-peer-sync-with-couchbase-lite/260

Hello - I am having a similar issue, but I have the Sync Gateway running on a separate AWS instance (I have already posted this as a separate topic before I came across this thread)

  • I am trying to connect to our Couchbase database from a Flutter application.
  • I installed the couchbase database on AWS http://x.x.x.198 (aws-marketplace/couchbase6.5.0-UbuntuLTS18.04)
  • I installed the sync gateway on seperate AWS instance http://x.x.x

The sync gateway config file :

{
"logging": {
"console": {
"log_keys": ["*"]
}
},
"CORS": {
"Origin": [
"*"
],
"LoginOrigin": [
"*"
],
"Headers": [
"Content-Type"
],
"MaxAge": 1728000
},
"adminInterface": "[127.0.0.1:4985](http://127.0.0.1:4985/)",
"interface": "[0.0.0.0:4984](http://0.0.0.0:4984/)",
"databases": {
"randr": {
"server": "[ec2-x-x-x-198.eu-west-2.compute.amazonaws.com:8091/](http://ec2-x-x-x-198.eu-west-2.compute.amazonaws.com:8091/)",
"bucket": "randr",
"username": "randr",
"password": "*************",
"enable_shared_bucket_access": true,

"import_docs": true,
"users": {
"GUEST": {
"disabled": true

},
"randr_public": {
"password": "********************",
"email": "*****************",
"admin_channels": [
"randr_public"
]
}
},
"use_views": true,
"sync": "function (doc, oldDoc) {if (doc._deleted) { return; } requireAccess(doc.channels); channel(doc.channels);}"
}
}
}

I get the following error in Flutter code :

E/CouchbaseLite/REPLICATOR(17577): {Repl#12}==> N8litecore4repl10ReplicatorE /data/user/0/com.registerandrecall.randrbuild/files/rr_public.cblite2/ ->ws://[ec2-18-x-x-198.eu-west-2.compute.amazonaws.com:4984/randr/_blipsync](http://ec2-18-x-x-198.eu-west-2.compute.amazonaws.com:4984/randr/_blipsync) @0x7cca31fac8
E/CouchbaseLite/REPLICATOR(17577): {Repl#12} Got LiteCore error: WebSocket error 1001 "WebSocket connection closed by peer"
I/call.randrbuil(17577): Waiting for a blocking GC ProfileSaver
I/call.randrbuil(17577): WaitForGcToComplete blocked ProfileSaver on HeapTrim for 19.579ms
E/CouchbaseLite/REPLICATOR(17577): {Repl#13}==> N8litecore4repl10ReplicatorE /data/user/0/com.registerandrecall.randrbuild/files/rr_public.cblite2/ ->ws://[ec2-18-x-x-198.eu-west-2.compute.amazonaws.com:4984/randr/_blipsync](http://ec2-18-x-x-198.eu-west-2.compute.amazonaws.com:4984/randr/_blipsync) @0x7d447368c8
E/CouchbaseLite/REPLICATOR(17577): {Repl#13} Got LiteCore error: WebSocket error 1001 "WebSocket connection closed by peer"
I/flutter (17577): start notification management for android ...
I/flutter (17577): Replocator -> ReplicatorActivityLevel.connecting
I/flutter (17577): Error in replicator: WebSocket connection closed by peer
I/flutter (17577): Replocator -> ReplicatorActivityLevel.connecting
I/flutter (17577): Error in replicator: WebSocket connection closed by peer
I/flutter (17577): Replocator -> ReplicatorActivityLevel.offline
I/flutter (17577): Replocator -> ReplicatorActivityLevel.connecting
I/flutter (17577): Error in replicator: WebSocket connection closed by peer
I/flutter (17577): Replocator -> ReplicatorActivityLevel.connecting
I/flutter (17577): Error in replicator: WebSocket connection closed by peer
I/flutter (17577): Replocator -> ReplicatorActivityLevel.offline
I/flutter (17577): Replocator -> ReplicatorActivityLevel.connecting
E/CouchbaseLite/REPLICATOR(17577): {Repl#14}==> N8litecore4repl10ReplicatorE /data/user/0/com.registerandrecall.randrbuild/files/rr_public.cblite2/ ->ws://[ec2-18-134-140-198.eu-west-2.compute.amazonaws.com:4984/randr/_blipsync](http://ec2-18-134-140-198.eu-west-2.compute.amazonaws.com:4984/randr/_blipsync) @0x7d447363c8
E/CouchbaseLite/REPLICATOR(17577): {Repl#14} Got LiteCore error: WebSocket error 1001 "WebSocket connection closed by peer"
I/flutter (17577): Error in replicator: WebSocket connection closed by peer
I/flutter (17577): Replocator -> ReplicatorActivityLevel.connecting
I/flutter (17577): Error in replicator: WebSocket connection closed by peer
I/flutter (17577): Replocator -> ReplicatorActivityLevel.offline

Sync gateway is running on correct port :

ubuntu@ip-x-x-x-195:/home/sync_gateway$ sudo lsof -i -P -n | grep LISTEN
systemd-r   735 systemd-resolve   13u  IPv4  17323      0t0  TCP [127.0.0.53:53](http://127.0.0.53:53/) (LISTEN)
sshd       1093            root    3u  IPv4  20932      0t0  TCP *:22 (LISTEN)
sshd       1093            root    4u  IPv6  20943      0t0  TCP *:22 (LISTEN)
sync_gate 12877    sync_gateway   11u  IPv6 144840      0t0  TCP *:4984 (LISTEN)
sync_gate 12877    sync_gateway   16u  IPv4 144842      0t0  TCP [127.0.0.1:4985](http://127.0.0.1:4985/) (LISTEN)

and the sg_info.log

2020-11-20T09:58:52.251Z [INF] DCP: c:randr-SGI Restarting vb 1019 using metadata sequence 4  (backfill 0 not in [4-4])
2020-11-20T09:58:52.252Z [INF] DCP: c:randr-SGI Restarting vb 1020 using metadata sequence 6  (backfill 6 not in [6-6])
2020-11-20T09:58:52.252Z [INF] DCP: c:randr-SGI Restarting vb 1021 using metadata sequence 6  (backfill 0 not in [6-6])
2020-11-20T09:58:52.252Z [INF] DCP: c:randr-SGI Restarting vb 1022 using metadata sequence 0  (backfill 0 not in [0-0])
2020-11-20T09:58:52.253Z [INF] DCP: c:randr-SGI Restarting vb 1023 using metadata sequence 5  (backfill 0 not in [5-5])
2020-11-20T09:58:52.253Z [INF] DCP: c:randr-SGI DCP feed starting with name SGI-v-2.8-commit--uuid-fe698846-2b16-11eb-bd8c-02227b0cd494
2020-11-20T09:58:52.253Z [INF] DCP: Starting mutation feed on bucket randr due to either channel cache mode or doc tracking (auto-import)
2020-11-20T09:58:52.253Z [INF] DCP: Using DCP feed for bucket: "randr" (based on feed_type specified in config file)
2020-11-20T09:58:52.287Z [INF] CBGoUtilsLogger: Using plain authentication for user <ud>randr</ud>
2020-11-20T09:58:52.300Z [INF] DCP: c:randr-SG DCP feed starting with name SG-v-2.8-commit--uuid-fe70c24a-2b16-11eb-bd8c-02227b0cd494
2020-11-20T09:58:52.301Z [INF] Cache: Waiting 976.270155ms for sequence allocation...
2020-11-20T09:58:52.340Z [INF] CBGoUtilsLogger: Using plain authentication for user <ud>randr</ud>
2020-11-20T09:58:52.387Z [INF] DCP: Backfill in progress: 0% (1 / 1882)
2020-11-20T09:58:53.283Z [INF] Using metadata purge interval of 3.00 days for tombstone compaction.
2020-11-20T09:58:53.283Z [INF] Created background task: "Compact" with interval 24h0m0s
2020-11-20T09:58:53.353Z [INF] Access: Computed roles for "":
2020-11-20T09:58:53.355Z [INF] Auth: Saved principal w/ name:, seq: #1198
2020-11-20T09:58:53.355Z [INF] Reset guest user to config
2020-11-20T09:58:53.356Z [INF] DCP: Received #1198 ("_user/")
2020-11-20T09:58:53.356Z [INF] Starting admin server on [127.0.0.1:4985](http://127.0.0.1:4985/)
2020-11-20T09:58:53.358Z [INF] Starting server on [0.0.0.0:4984](http://0.0.0.0:4984/) ...
2020-11-20T09:58:58.360Z [INF] Replicate: Starting sg-replicate replications...

@randr Looks like you have opened a separate post so lets keep the discussion in one thread.

I am trying to filter data on sync gateway from couchbase server to get only specific records but am not able to do that. there are two entries on my server “apple” and “avocado” wherein I am trying to filter those with text as “apple” and show the on sync gateway. Please guide me with the same.

Below is my syncgateway configuration file.

“databases”: {
“grocery-sync”: {
“server”: “http://10.55.18.1:8091”,
“bucket”: “grocery-sync”,
“username”: “user”,
“password”: “password”,
“enable_shared_bucket_access”: true,
“import_docs”: true,
“num_index_replicas”: 0,
“users”: {
“GUEST”: {“disabled”: false, “admin_channels”: ["*"] }
},
“import_filter”: function(doc) { if (doc.text == "apple") { return } },

  "allow_conflicts": false,
  "revs_limit": 20
}

}
}

@Mayuri Please open a separate post with relevant subject line. You question appears to be unrelated to the original thread.

I have opened a separate post but couldn’t get reply on it. please find below post.

In future, please assign right categories (and tags) to your questions so it reaches the right team. You had your mobile question tagged under server which was likely the reason why it was missed