【发布时间】:2021-04-30 21:46:29
【问题描述】:
【问题讨论】:
-
请不要发布图片,随着时间的推移,它们最终会变成断开的链接,更重要的是它可以防止有视力障碍的人提供帮助。阅读pouchdb.com/guides/replication.html#live%E2%80%93replication,它讨论了您发布的问题,特别是
retry选项和paused同步事件。
【问题讨论】:
retry 选项和paused 同步事件。
好的,对不起图片。
我读到了 pouchdb 中的复制和使用重试选项
我的代码:
this.service.synch().then((data) => {
this.lottieSpashScreen.hide();
}).catch((err) => {
console.log('no network or couch not respond')
this.lottieSpashScreen.hide();
});
在役:
synch() {
let optionsToAndFrom = {
live: true,
retry: true,
continuous: true
};
this.db.replicate.to(this.remote, optionsToAndFrom)
return this.db.replicate.from(this.remote)
.on('complete', (info) => {
this.db.replicate.from(this.remote, optionsToAndFrom)
})
.on('error', (info) => {
console.log('error')
})}
有时如果设备长时间断开连接,复制会停止,我必须重新启动应用程序。
在网络上我可以看到停止请求的时间超过了四分钟
编辑:在浏览器中一切正常,没有问题。
问题出在安卓设备上
编辑:
当我启动应用程序和网络无法连接时,我可以在日志中看到:
net::ERR_INTERNET_DISCONNECTED
那太好了。
但是当我启动应用程序和网络连接并在几秒钟后断开连接时,我只能在网络中看到该请求处于待处理状态而没有错误。当我在大约几分钟后打开网络时,此请求已执行,但当我在大约五分钟后关闭网络时,此请求处于待处理状态。
【讨论】:
back_off_function 实现自定义回退功能,请阅读Customizing retry for replication。您需要的一切都在那里。
heartbeat 和timeout 高级复制选项?