added connection timeout and refactored code

This commit is contained in:
Tarun Singh
2021-11-22 03:21:53 -05:00
parent 3306f4a8e0
commit 35da8c78f4
2 changed files with 11 additions and 2 deletions

View File

@@ -321,7 +321,12 @@ class Monitor extends BeanModel {
}
} else if (this.type === "mqtt") {
try {
bean.msg = await mqttAsync(this.url, this.mqttPort, this.mqttUsername, this.mqttPassword, this.mqttTopic, this.mqttSuccessMessage);
bean.msg = await mqttAsync(this.url, this.mqttTopic, this.mqttSuccessMessage, {
mqttPort: this.mqttPort,
mqttUsername: this.mqttUsername,
mqttPassword: this.mqttPassword,
interval: this.interval,
});
bean.status = UP;
} catch (error) {
bean.status = DOWN;