Skip to content

Commit 7b4fb11

Browse files
committed
fix(connection): Prevent timouts
1 parent b74068b commit 7b4fb11

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

MqttClient.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,10 @@
11
const MQTT = require('async-mqtt')
2-
//const RateLimiter = require('./RateLimiter')
32
const RateLimiter = require('./RateLimiter2')
43

54
function MqttClient(options, callbacksObj) {
65
this.options = options
76
this.client = null
87

9-
// this.rater = new RateLimiter({
10-
// highWaterMark: 3,
11-
// intervalInSec: 60,
12-
// onExhaustionCb: () => {
13-
// this.disconnect()
14-
// console.log(
15-
// 'Too many connection attempts to the virtual smart home backend. Please try restarting your flows, Node-RED or even your entire system.'
16-
// )
17-
// setTimeout(
18-
// () => this.handleOnError({ code: 'connection quota exhausted' }),
19-
// 2000
20-
// )
21-
// },
22-
// })
23-
248
this.rater = new RateLimiter(
259
[{ period: 60000, limit: 4, penalty: 0 }],
2610
(group) => {
@@ -46,7 +30,6 @@ function MqttClient(options, callbacksObj) {
4630
}
4731

4832
this.handleOnConnect = function () {
49-
//this.rater.execute(() => callbacksObj['onConnect']())
5033
this.rater.execute('onConnect_group', () => callbacksObj['onConnect']())
5134
}
5235

connection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ module.exports = function (RED) {
397397
}
398398

399399
this.disconnect = async function () {
400-
if (this.isDisconnecting) {
400+
if (!this.isConnected || this.isDisconnecting) {
401401
return
402402
}
403403

0 commit comments

Comments
 (0)