| 495 | this._reconnectTimeout = setTimeout( |
| 496 | async () => { |
| 497 | if (!!this.socket && this.socket.readyState !== this.socket.CLOSED) return; |
| 498 | this.logger?.debug(`Reconnecting... (attempt ${this._retried})`); |
| 499 | try { |
| 500 | await this.connect(10_000); |
| 501 | } catch (e) { |
| 502 | if (this._retried) |
| 503 | this.logger?.warn(`Failed to reconnect (attempt ${this._retried - 1})`, e); |
| 504 | } |
| 505 | }, |
| 506 | Math.min(30_000, this._retried * 1_000), |
| 507 | ); |
| 508 | } else { |
| 509 | this.logger?.debug('Auto-reconnect limit reached. Cleaning up...'); |
| 510 | this.cleanup(); |