gpt4 book ai didi

android - Couchbase Lite 拉取复制在示例 Couchbase 移动端到端测试项目中失败并出现错误

转载 作者:行者123 更新时间:2023-12-03 13:40:36 25 4
gpt4 key购买 nike

我开始使用 Couchbase Mobile。我最感兴趣的功能(目前)是PULL复制(使移动设备上的数据与后端数据库保持同步)。

我按照 Using Docker to develop with Couchbase Mobile 中描述的步骤进行操作并在本地部署了 Couchbase 服务器 (enterprise-6.5.0) 和同步网关 (2.7.0-enterprise)。我添加了 beer-sample数据库(有〜8400个文件),现在我正试图在一个android应用程序上复制它。我定制了Userprofile Couchbase Mobile Android项目,我将它指向我的本地同步网关。我有一段代码要复制如下:

  public static void startPullReplication() {
Log.i("Pull", "Start pull beer-sample");
URI url = null;
try {
url = new URI(String.format("%s/%s", "ws://10.0.1.7:4984", beerSampleDbName));
} catch (URISyntaxException e) {
e.printStackTrace();
}

ReplicatorConfiguration config =
new ReplicatorConfiguration(beerSampleDatabase, new URLEndpoint(url)); // <1>
config.setReplicatorType(ReplicatorConfiguration.ReplicatorType.PULL); // <2>
config.setContinuous(true); // <3>
config.setAuthenticator(new BasicAuthenticator("admin", "password")); // <4>
// config.setChannels(Arrays.asList("channel." + "admin")); // <5>

replicator = new Replicator(config);
replicatorListenerToken =
replicator.addChangeListener(
new ReplicatorChangeListener() {
@Override
public void changed(ReplicatorChange change) {
Log.i("Pull", "Changed pull beer sample : " + change.getStatus());
if (change
.getReplicator()
.getStatus()
.getActivityLevel()
.equals(Replicator.ActivityLevel.IDLE)) {
Log.i("Replication Comp Log", "Scheduler Completed");
}
if (change
.getReplicator()
.getStatus()
.getActivityLevel()
.equals(Replicator.ActivityLevel.STOPPED)
|| change
.getReplicator()
.getStatus()
.getActivityLevel()
.equals(Replicator.ActivityLevel.OFFLINE)) {
Log.i("Rep Scheduler Log", "ReplicationTag Stopped");
}
}
});
replicator.start();

Log.i("Pull", "Replication beer-sample started");
}

并收听数据库中的更改,如下所示:

private void registerForDatabaseChanges() {
beerSampleListenerToken =
beerSampleDatabase.addChangeListener(
new DatabaseChangeListener() {
Integer i=0;
@Override
public void changed(@NonNull DatabaseChange change) {
Log.i("DatabaseChangeEvent", String.valueOf(i));
i++;
for (String docId : change.getDocumentIDs()) {
Document doc = beerSampleDatabase.getDocument(docId);
if (doc != null) {
Log.i("DatabaseChangeEvent", doc.getId() + ": Document was added/updated");
} else {
Log.i("DatabaseChangeEvent", docId + "Document was deleted");
}
}
}
});
}


现在,当我运行该应用程序时,我会收到以下日志。
2020-02-11 15:44:46.420 22513-22513/com.cbmob.testapp W/CouchbaseLite/DATABASE: Database.log.getFile().getConfig() is null, meaning file logging is disabled.  Log files required for product support are not being generated.
2020-02-11 15:44:46.615 22513-22545/com.cbmob.testapp D/OpenGLRenderer: HWUI GL Pipeline
2020-02-11 15:44:46.744 22513-22545/com.cbmob.testapp I/zygote: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
2020-02-11 15:44:46.744 22513-22545/com.cbmob.testapp I/OpenGLRenderer: Initialized EGL, version 1.4
2020-02-11 15:44:46.744 22513-22545/com.cbmob.testapp D/OpenGLRenderer: Swap behavior 1
2020-02-11 15:44:46.745 22513-22545/com.cbmob.testapp W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2020-02-11 15:44:46.745 22513-22545/com.cbmob.testapp D/OpenGLRenderer: Swap behavior 0
2020-02-11 15:44:46.752 22513-22545/com.cbmob.testapp D/EGL_emulation: eglCreateContext: 0xa9f30d40: maj 3 min 0 rcv 3
2020-02-11 15:44:46.765 22513-22545/com.cbmob.testapp D/EGL_emulation: eglMakeCurrent: 0xa9f30d40: ver 3 0 (tinfo 0x9f7bf880)
2020-02-11 15:44:46.976 22513-22545/com.cbmob.testapp D/EGL_emulation: eglMakeCurrent: 0xa9f30d40: ver 3 0 (tinfo 0x9f7bf880)



2020-02-11 15:44:56.458 22513-22513/com.cbmob.testapp I/Pull: Start pull beer-sample
2020-02-11 15:44:56.480 22513-22576/com.cbmob.testapp W/CouchbaseLite/NETWORK: C4Socket.open() socket -> 2852069288
2020-02-11 15:44:56.480 22513-22576/com.cbmob.testapp W/CouchbaseLite/NETWORK: C4Socket.open() clazz -> com.couchbase.lite.internal.replicator.CBLWebSocket
2020-02-11 15:44:56.482 22513-22513/com.cbmob.testapp I/Pull: Replication beer-sample started
2020-02-11 15:44:56.497 22513-22513/com.cbmob.testapp I/Pull: Changed pull beer sample : Status{activityLevel=CONNECTING, progress=Progress{completed=0, total=0}, error=null}
2020-02-11 15:44:56.519 22513-22576/com.cbmob.testapp D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2020-02-11 15:44:56.528 22513-22576/com.cbmob.testapp E/CouchbaseLite/NETWORK: CBLWebSocket.socket_open()
2020-02-11 15:44:56.582 22513-22576/com.cbmob.testapp W/CouchbaseLite/NETWORK: C4Socket.write() handle -> 2852069288
2020-02-11 15:44:56.586 22513-22576/com.cbmob.testapp W/CouchbaseLite/NETWORK: completedWrite(long) handle -> 2852069288, byteCount -> 68
2020-02-11 15:44:56.591 22513-22513/com.cbmob.testapp I/Pull: Changed pull beer sample : Status{activityLevel=BUSY, progress=Progress{completed=0, total=0}, error=null}
2020-02-11 15:44:56.591 22513-22576/com.cbmob.testapp W/CouchbaseLite/NETWORK: C4Socket.write() handle -> 2852069288
2020-02-11 15:44:56.592 22513-22576/com.cbmob.testapp W/CouchbaseLite/NETWORK: completedWrite(long) handle -> 2852069288, byteCount -> 121
2020-02-11 15:44:56.605 22513-22577/com.cbmob.testapp W/CouchbaseLite/NETWORK: C4Socket.completedReceive() handle -> 2852069288
2020-02-11 15:44:56.608 22513-22577/com.cbmob.testapp I/chatty: uid=10086(com.cbmob.testapp) Thread-9 identical 1 line
2020-02-11 15:44:56.612 22513-22577/com.cbmob.testapp W/CouchbaseLite/NETWORK: C4Socket.completedReceive() handle -> 2852069288
2020-02-11 15:44:56.627 22513-22513/com.cbmob.testapp I/Pull: Changed pull beer sample : Status{activityLevel=IDLE, progress=Progress{completed=0, total=0}, error=null}
2020-02-11 15:44:56.628 22513-22513/com.cbmob.testapp E/Replication Comp Log: Scheduler Completed

显然,没有记录数据库中的文档更改。由此,我假设复制根本没有发生。我不确定如何进行调试。如果有人对如何调试有任何指示,我将不胜感激。如果需要,我可以发布同步网关日志。

如果有人有任何博客点或项目的链接来解释如何让所有部分一起工作,请分享。

期待听到人们的回音。

最佳答案

在经历了整个过程的痛苦旅程并且从模拟器的调试日志中没有得到任何线索之后,我尝试在真实设备上运行该应用程序并记录了一个错误日志语句,其中说明了 的效果。不允许与网络通信 (我丢失了确切的日志语句)。在深入研究该问题后,我了解到我的目标是 API 28,并且如文档所述 here ,对于 API >= 28,cleartextTrafficPermitted 的默认值是 false .将其设置为 true解决了这个问题。

我希望这可以帮助某人节省时间。

关于android - Couchbase Lite 拉取复制在示例 Couchbase 移动端到端测试项目中失败并出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60166800/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com