static: backoff retrying to connect to ws
This commit is contained in:
parent
89400b4ea4
commit
a91d0ddc6c
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -27,6 +27,8 @@ export class Messages extends LitElement {
|
||||||
|
|
||||||
messageSocket?: WebSocket;
|
messageSocket?: WebSocket;
|
||||||
|
|
||||||
|
retryDelay: number = 200;
|
||||||
|
|
||||||
createRenderRoot() {
|
createRenderRoot() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -47,9 +49,10 @@ export class Messages extends LitElement {
|
||||||
this.messageSocket.addEventListener("close", (e) => {
|
this.messageSocket.addEventListener("close", (e) => {
|
||||||
console.debug(`passbook/messages: closed ws connection: ${e}`);
|
console.debug(`passbook/messages: closed ws connection: ${e}`);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
console.debug(`passbook/messages: reconnecting ws`);
|
console.debug(`passbook/messages: reconnecting ws in ${this.retryDelay}`);
|
||||||
this.connect();
|
this.connect();
|
||||||
}, 1000);
|
}, this.retryDelay);
|
||||||
|
this.retryDelay = this.retryDelay * 2;
|
||||||
});
|
});
|
||||||
this.messageSocket.addEventListener("message", (e) => {
|
this.messageSocket.addEventListener("message", (e) => {
|
||||||
const container = <HTMLElement>(
|
const container = <HTMLElement>(
|
||||||
|
|
Reference in New Issue