当我从我的反应本机Android应用程序(使用Kotlin)启动复制过程时,如果我不配置Sync Gateway数据库中的自定义范围和集合,则默认集合会正确同步。但是,使用自定义集合时,数据不同步。我在同步网关中收到错误日志,指示问题。
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
{
"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
}
{
"name": "syncuser",
"admin_channels": [
"!",
"*",
"project1"
],
"collection_access": {
"scope1": {
"collection1": {
"admin_channels": [
"!",
"*",
"project1"
],
"all_channels": [
"!",
"*",
"project1"
]
}
}
},
"email": "",
"disabled": false
}
反应本机andriod代码(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()
我怎么能解决这个问题? 我想通过SYN Gateway使我的自定义集合同步到我的Couchbase服务器。
Brooks已经回答了您的问题。在Couchbase论坛上。在这里引用要点:
CBL客户端上的一组集合需要匹配,或者是Sync Gateway上的集合的子集。