1
0
forked from Kieran/snort

fix: reconnect spam

This commit is contained in:
kieran 2024-04-25 12:35:24 +01:00
parent 52688e6389
commit d0d30cb94f
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941

View File

@ -94,7 +94,11 @@ export class Connection extends EventEmitter<ConnectionTypeEvents> implements Co
}
async connect() {
// already connected
if (this.isOpen) return;
// wait for re-connect timer
if (this.ReconnectTimer) return;
try {
if (this.info === undefined) {
const u = new URL(this.address);
@ -177,6 +181,7 @@ export class Connection extends EventEmitter<ConnectionTypeEvents> implements Co
`Closed (code=${e.code}), trying again in ${(this.ConnectTimeout / 1000).toFixed(0).toLocaleString()} sec`,
);
this.ReconnectTimer = setTimeout(() => {
this.ReconnectTimer = undefined;
try {
this.connect();
} catch {