fix: reconnect spam
This commit is contained in:
@ -94,7 +94,11 @@ export class Connection extends EventEmitter<ConnectionTypeEvents> implements Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
async connect() {
|
async connect() {
|
||||||
|
// already connected
|
||||||
if (this.isOpen) return;
|
if (this.isOpen) return;
|
||||||
|
// wait for re-connect timer
|
||||||
|
if (this.ReconnectTimer) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.info === undefined) {
|
if (this.info === undefined) {
|
||||||
const u = new URL(this.address);
|
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`,
|
`Closed (code=${e.code}), trying again in ${(this.ConnectTimeout / 1000).toFixed(0).toLocaleString()} sec`,
|
||||||
);
|
);
|
||||||
this.ReconnectTimer = setTimeout(() => {
|
this.ReconnectTimer = setTimeout(() => {
|
||||||
|
this.ReconnectTimer = undefined;
|
||||||
try {
|
try {
|
||||||
this.connect();
|
this.connect();
|
||||||
} catch {
|
} catch {
|
||||||
|
Reference in New Issue
Block a user