diff --git a/index.ts b/index.ts index 837a31c..a617fb9 100755 --- a/index.ts +++ b/index.ts @@ -143,6 +143,7 @@ async function main() { updateCLI(); reconnectServers(config); } + removeExpiredMailboxes(); }, 2000); diff --git a/subscriptionHandler.ts b/subscriptionHandler.ts index 102250b..da556c1 100644 --- a/subscriptionHandler.ts +++ b/subscriptionHandler.ts @@ -23,7 +23,7 @@ export class Mailbox implements Subscriber { } get isExpired() { - if (this.ws) return false; + if (this.ws && this.ws.readyState == 1) return false; const today = new Date(); return this.expiryDate < today; diff --git a/websocket-handler.ts b/websocket-handler.ts index f22349b..9af5d42 100644 --- a/websocket-handler.ts +++ b/websocket-handler.ts @@ -208,7 +208,6 @@ export function processMessage( // MAILBOX export function removeExpiredMailboxes() { - const today = new Date(); mailboxes.forEach((mailbox) => { if (mailbox.isExpired) removeMailbox(mailbox); });