I am new to Couchbase and need guidance to resolve the following issue:
When I start a replication process from my React Native Android app (using Kotlin), the default collection syncs correctly if I do not configure a custom scope and collection in the Sync Gateway database. However, when using a custom collection, the data does not sync. I receive an error log in the Sync Gateway indicating a problem.
2025-02-05 11:00:26 2025-02-05T05:30:26.057Z [INF] HTTP: c:#008 db:sampledb GET /sampledb/_blipsync (as <ud>syncuser</ud>)
2025-02-05 11:00:26 2025-02-05T05:30:26.057Z [INF] HTTP+: c:[53456386] db:sampledb #008: --> 101 [53456386] Upgraded to WebSocket protocol BLIP_3+CBMobile_3 (as <ud>syncuser</ud>) (0.0 ms)
2025-02-05 11:00:26 2025-02-05T05:30:26.057Z [INF] WS: c:#008 db:sampledb Start BLIP/Websocket handler
2025-02-05 11:00:26 2025-02-05T05:30:26.066Z [INF] SyncMsg: c:[53456386] db:sampledb #1: Type:getCheckpoint --> 400 Collection property not specified and default collection is not configured for this database Time:55.009µs
2025-02-05 11:00:26 2025-02-05T05:30:26.068Z [INF] SyncMsg: c:[53456386] db:sampledb #2: Type:proposeChanges --> 400 Collection property not specified and default collection is not configured for this database Time:12.612µs
2025-02-05 11:00:26 2025-02-05T05:30:26.073Z [INF] SyncMsg: c:[53456386] db:sampledb #3: Type:subChanges --> 400 Collection property not specified and default collection is not configured for this database Time:20.531µs
2025-02-05 11:00:26 2025-02-05T05:30:26.082Z [INF] WS: c:#008 db:sampledb Error: receiveLoop exiting with WebSocket error: failed to get reader: received close frame: status = StatusCode(4002) and reason = "Unrecognized collection"
2025-02-05 11:00:26 2025-02-05T05:30:26.133Z [INF] WS: c:#008 db:sampledb BLIP/Websocket Handler exited with error: failed to get reader: received close frame: status = StatusCode(4002) and reason = "Unrecognized collection"
2025-02-05 11:00:26 2025-02-05T05:30:26.133Z [INF] HTTP: c:[53456386] db:sampledb #008: --> BLIP+WebSocket connection error: failed to get reader: received close frame: status = StatusCode(4002) and reason = "Unrecognized collection"
2025-02-05 11:00:26 2025-02-05T05:30:26.133Z [INF] HTTP: c:[53456386] db:sampledb #008: --> BLIP+WebSocket connection closed
Configuration in syn gateway
1.) DB config
{
"bucket": "sample",
"scopes": {
"scope1": {
"collections": {
"collection1": {
"sync": "function(doc){channel(\"*\");}",
"import_filter": "function(doc) { return true; }"
}
}
}
},
"name": "sampledb",
"import_docs": true,
"enable_shared_bucket_access": true,
"num_index_replicas": 0
}
2.) User config
{
"name": "syncuser",
"admin_channels": [
"!",
"*",
"project1"
],
"collection_access": {
"scope1": {
"collection1": {
"admin_channels": [
"!",
"*",
"project1"
],
"all_channels": [
"!",
"*",
"project1"
]
}
}
},
"email": "",
"disabled": false
}
React native andriod code(Kotlin)
var database = Database("sampledb")
val config = ReplicatorConfigurationFactory.newConfig(
collections = mapOf(database.collections to null),
target = URLEndpoint(URI("ws://IPADDRESS/sampledb")),
type = ReplicatorType.PUSH_AND_PULL,
authenticator = BasicAuthenticator("syncuser", "helloworld".toCharArray())
)
val replicator = Replicator(config)
replicator.start()
How can I resolve this issue?