Skip to content

Commit a0a23ba

Browse files
committed
fix(connection): Use rate-limiter only for desired state changes, not for reported
1 parent 423fd49 commit a0a23ba

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

connection.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,18 @@ module.exports = function (RED) {
129129
}
130130

131131
const publishCb = () => {
132-
this.mqttClient.publish(
133-
`$aws/things/${this.credentials.thingId}/shadow/name/${deviceId}/update`,
134-
payload
135-
)
132+
if (!this.isDisconnecting) {
133+
this.mqttClient.publish(
134+
`$aws/things/${this.credentials.thingId}/shadow/name/${deviceId}/update`,
135+
payload
136+
)
137+
}
136138
}
137139

138-
if (!this.isDisconnecting) {
140+
if (type === 'desired') {
139141
this.rater.execute(`${deviceId}`, publishCb.bind(this))
142+
} else {
143+
publishCb()
140144
}
141145
}
142146

0 commit comments

Comments
 (0)