From 26625a58d0831f023cf682b11116a02ed724d9f7 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 31 Aug 2018 23:24:43 -0400 Subject: [PATCH] spread out reconnects between 2 and 5 min --- src/services/notifications.service.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/services/notifications.service.ts b/src/services/notifications.service.ts index d6f2300b6c6..9ad374bf65b 100644 --- a/src/services/notifications.service.ts +++ b/src/services/notifications.service.ts @@ -179,7 +179,7 @@ export class NotificationsService implements NotificationsServiceAbstraction { } catch { } if (!this.connected) { - this.reconnectTimer = setTimeout(() => this.reconnect(sync), 120000); + this.reconnectTimer = setTimeout(() => this.reconnect(sync), this.random(120000, 300000)); } } @@ -189,4 +189,10 @@ export class NotificationsService implements NotificationsServiceAbstraction { } return false; } + + private random(min: number, max: number) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min + 1)) + min; + } }