diff --git a/lib/mqtt-subscriber.ts b/lib/mqtt-subscriber.ts index 1ab42ae..c55c018 100644 --- a/lib/mqtt-subscriber.ts +++ b/lib/mqtt-subscriber.ts @@ -20,7 +20,6 @@ interface OwnTracksMessage { class MQTTSubscriber { private client: mqtt.MqttClient | null = null; private reconnectAttempts = 0; - private maxReconnectAttempts = 10; private isConnecting = false; constructor( @@ -80,11 +79,9 @@ class MQTTSubscriber { this.client.on('reconnect', () => { this.reconnectAttempts++; - console.log(`Reconnecting to MQTT broker (attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts})`); - - if (this.reconnectAttempts >= this.maxReconnectAttempts) { - console.error('Max reconnect attempts reached, giving up'); - this.client?.end(); + // Log less frequently to avoid spam (every 10th attempt after attempt 10) + if (this.reconnectAttempts <= 10 || this.reconnectAttempts % 10 === 0) { + console.log(`Reconnecting to MQTT broker (attempt ${this.reconnectAttempts})`); } });