So I built an app with Ionic DB. I used .watch() to get real time update. While it is working fine in Chrome, I kept getting the following error in Safari 10-15 seconds after connection:
[Error] Connection Failed: – “Unexpected disconnect with error code 1006.”
next (main.js:114921)
onclose (main.js:99780)
n (polyfills.js:2:27346)
invokeTask (polyfills.js:3:9729)
onInvokeTask (main.js:43185)
invokeTask (polyfills.js:3:9672)
runTask (polyfills.js:3:7094)
invoke (polyfills.js:3:10844)
[Error] Retrying in 5 seconds.
next (main.js:114923)
onclose (main.js:99780)
n (polyfills.js:2:27346)
invokeTask (polyfills.js:3:9729)
onInvokeTask (main.js:43185)
invokeTask (polyfills.js:3:9672)
runTask (polyfills.js:3:7094)
invoke (polyfills.js:3:10844)
[Error] Received an error: [object CloseEvent]
(anonymous function) (main.js:114391)
__tryOrUnsub (main.js:1293)
error (main.js:1254)
_error (main.js:1198)
error (main.js:1172)
error (main.js:5093)
onclose (main.js:99786)
n (polyfills.js:2:27346)
invokeTask (polyfills.js:3:9729)
onInvokeTask (main.js:43185)
invokeTask (polyfills.js:3:9672)
runTask (polyfills.js:3:7094)
invoke (polyfills.js:3:10844)
To reproduce the error on Safari:
export class ChatsPage {
public message:string;
public chats: Array;constructor(public db: Database) {
this.db.connect();
this.db.collection(‘chats’).watch().subscribe( (chats) => {
this.chats = chats;
}, (error) => {
console.error(error);
});
}
sendMessage() {
this.db.collection(‘chats’).store({text: this.message, time: Date.now()});
}
Load the page and wait for 10-15 seconds.
Any kind soul who use Ionic DB please let me know if this code is working on your Safari browser.