mqtt 5.8.0 → 5.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mqtt",
3
3
  "description": "A library for the MQTT protocol",
4
- "version": "5.8.0",
4
+ "version": "5.8.1",
5
5
  "contributors": [
6
6
  "Adam Rudd <adamvrr@gmail.com>",
7
7
  "Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)",
package/src/lib/client.ts CHANGED
@@ -732,6 +732,13 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac
732
732
  this.log('connect :: calling method to clear reconnect')
733
733
  this._clearReconnect()
734
734
 
735
+ if (this.disconnected && !this.reconnecting) {
736
+ this.incomingStore = this.options.incomingStore || new Store()
737
+ this.outgoingStore = this.options.outgoingStore || new Store()
738
+ this.disconnecting = false
739
+ this.disconnected = false
740
+ }
741
+
735
742
  this.log(
736
743
  'connect :: using streamBuilder provided to client to create stream',
737
744
  )
@@ -1459,6 +1466,11 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac
1459
1466
  })
1460
1467
  if (this._deferredReconnect) {
1461
1468
  this._deferredReconnect()
1469
+ } else if (
1470
+ this.options.reconnectPeriod === 0 ||
1471
+ this.options.manualConnect
1472
+ ) {
1473
+ this.disconnecting = false
1462
1474
  }
1463
1475
  }
1464
1476
 
@@ -2097,11 +2109,11 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac
2097
2109
  /**
2098
2110
  * Reschedule the ping interval
2099
2111
  */
2100
- public reschedulePing() {
2112
+ public reschedulePing(force = false) {
2101
2113
  if (
2102
2114
  this.keepaliveManager &&
2103
2115
  this.options.keepalive &&
2104
- this.options.reschedulePings
2116
+ (force || this.options.reschedulePings)
2105
2117
  ) {
2106
2118
  this._reschedulePing()
2107
2119
  }
@@ -56,7 +56,7 @@ const handle: PacketHandler = (client, packet, done) => {
56
56
  break
57
57
  case 'pingresp':
58
58
  client.log('_handlePacket :: received pingresp')
59
- client.reschedulePing()
59
+ client.reschedulePing(true)
60
60
  done()
61
61
  break
62
62
  case 'disconnect':