File tree Expand file tree Collapse file tree 2 files changed +1
-18
lines changed Expand file tree Collapse file tree 2 files changed +1
-18
lines changed Original file line number Diff line number Diff line change 1
1
const MQTT = require ( 'async-mqtt' )
2
- //const RateLimiter = require('./RateLimiter')
3
2
const RateLimiter = require ( './RateLimiter2' )
4
3
5
4
function MqttClient ( options , callbacksObj ) {
6
5
this . options = options
7
6
this . client = null
8
7
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
-
24
8
this . rater = new RateLimiter (
25
9
[ { period : 60000 , limit : 4 , penalty : 0 } ] ,
26
10
( group ) => {
@@ -46,7 +30,6 @@ function MqttClient(options, callbacksObj) {
46
30
}
47
31
48
32
this . handleOnConnect = function ( ) {
49
- //this.rater.execute(() => callbacksObj['onConnect']())
50
33
this . rater . execute ( 'onConnect_group' , ( ) => callbacksObj [ 'onConnect' ] ( ) )
51
34
}
52
35
Original file line number Diff line number Diff line change @@ -397,7 +397,7 @@ module.exports = function (RED) {
397
397
}
398
398
399
399
this . disconnect = async function ( ) {
400
- if ( this . isDisconnecting ) {
400
+ if ( ! this . isConnected || this . isDisconnecting ) {
401
401
return
402
402
}
403
403
You can’t perform that action at this time.
0 commit comments