Reputation: 41
I have a problem with replicate when I turn off network and after few seconds turn on network.
After turn on network I must wait on replicate sync between 3-5 minutes:
On the prod env thi can be problematic.
Any ideas ?
Upvotes: 1
Views: 293
Reputation: 41
Okay, sorry for image.
I was read about replication in pouchdb and using retry option
My code:
this.service.synch().then((data) => {
this.lottieSpashScreen.hide();
}).catch((err) => {
console.log('no network or couch not respond')
this.lottieSpashScreen.hide();
});
In service:
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')
})}
Sometimes if a device is disconnected a long of time , replication stop and I have to restart app.
ON the network I can see that stalled on request is over four minutes
Edit: In browser everything working okay, without problem.
Problem is on device with android
EDIT :
When I started App and network not connect I can see in log :
net::ERR_INTERNET_DISCONNECTED
And thats great.
But when I started app and network connect and after few seconds disconnected I can see only in network that request is in pending status without error. When I turn on network after about minutes this request exectued but when I network off after about five minutes this request is in pending without changes status.
Upvotes: 1