Skip to content

Commit

Permalink
mqttTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
arteck authored Nov 10, 2023
1 parent 70711f2 commit 7581715
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/mqtt-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const net = require('net');

class MqttServer {
constructor(adapter) {

Check failure on line 8 in lib/mqtt-server.js

View workflow job for this annotation

GitHub Actions / check-and-lint

Trailing spaces not allowed
this.port = -1;
this.notAuthorizedClients = [];
this.adapter = adapter;
Expand Down Expand Up @@ -276,7 +277,7 @@ class MqttServer {
if (!this.devices[clientId])
this.devices[clientId] = {};

const interval = 70 * 1000;
const interval = this.adapter.config.mqttTimeout * 1000;

this.devices[clientId].timeoutNoUpdate = this.adapter.setTimeout(async () => {
try {
Expand All @@ -288,7 +289,7 @@ class MqttServer {
this.adapter.log.debug(`[MQTT] ${ipMsg} NOT ALIVE - last contact ${Math.round(diff / 1000)}s (${diff}ms) ago`);
this.setIsAlive(clientId, false, 'client did not send message for more than 70 seconds');
} else {
this.adapter.log.warn(`[MQTT] ${ipMsg} Please open a issue on Github, this should never happen: scheduleCheckIfStillActive() timeout, and last contact was less than 70s ago.`);
this.adapter.log.warn(`[MQTT] ${ipMsg} This should never happen: scheduleCheckIfStillActive() timeout, and last contact was less than ${this.adapter.config.mqttTimeout} sec ago.`);
this.adapter.log.warn(`[MQTT] ${ipMsg} is alive - last contact ${Math.round(diff / 1000)}s (${diff}ms) ago`);
this.setIsAlive(clientId, true, `alive check is successful (last contact: ${Math.round(diff / 1000)}s ago)`);
}
Expand Down

0 comments on commit 7581715

Please sign in to comment.