-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
MQTTjs Version
5.13.2
Broker
mosquitto
Environment
NodeJS
Description
If I try to publish messages with QoS > 0 during a reconnection, while the messages in the outgoing store are being sent (with startStreamProcess
), the processing of the messages is queued in _storeProcessingQueue
.
If a disconnection occur during this phase, all the messages are discarded here with _flushStoreProcessingQueue
.
I think the expected behaviour should be having them saved in the outgoing storage, like it happen when I publish messages during a disconnection.
I'm using this library in a react-native project (but the problem should be also present in other environments).
Minimal Reproduction
Unfortunately I can only reproduce this manually. What I'm doing to reproduce this is to have a good number of messages in the outgoing store and during the processing of the outgoing store stream I block the connection from the app to the broker with a firewall rule. Not sure how to automate this or write a test for it.
Debug logs
...
LOG publish :: message `...` to topic `...`
LOG publish :: message `...` to topic `...`
LOG publish :: message `...` to topic `...`
LOG publish :: message `...` to topic `...`
LOG publish :: message `...` to topic `...`
LOG publish :: message `...` to topic `...`
LOG publish :: message `...` to topic `...`
LOG publish :: message `...` to topic `...`
LOG publish :: message `...` to topic `...`
LOG publish :: message `...` to topic `...`
LOG publish :: message `...` to topic `...`
LOG publish :: message `...` to topic `...`
LOG publish :: message `...` to topic `...`
LOG onKeepaliveTimeout :: calling _cleanUp with force true
LOG _cleanUp :: forced? true
LOG _cleanUp :: (927d2004-8549-4345-b861-d0cb0d44dde0) :: destroying stream
LOG _cleanUp :: client not disconnecting/reconnecting. Clearing and resetting reconnect.
LOG _clearReconnect : clearing reconnect timer
LOG _setupReconnect :: emit `offline` state
LOG _setupReconnect :: set `reconnecting` to `true`
LOG _setupReconnect :: setting reconnectTimer for 15000 ms
LOG _destroyKeepaliveManager :: destroying keepalive manager
LOG (927d2004-8549-4345-b861-d0cb0d44dde0)stream :: on close
LOG _flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function
LOG stream: emit close to MqttClient
LOG close :: connected set to `false`
LOG close :: clearing connackTimer
LOG close :: calling _setupReconnect
LOG _setupReconnect :: doing nothing...
# here the remove and _flushStoreProcessingQueue are being called
LOG store cb put [Error: Connection closed]
LOG publish cb [Error: Connection closed undefined]
LOG store cb put [Error: Connection closed]
LOG publish cb [Error: Connection closed undefined]
LOG store cb put [Error: Connection closed]
LOG publish cb [Error: Connection closed undefined]
LOG store cb put [Error: Connection closed]
LOG publish cb [Error: Connection closed undefined]
LOG store cb put [Error: Connection closed]
LOG publish cb [Error: Connection closed undefined]
LOG store cb put [Error: Connection closed]
LOG publish cb [Error: Connection closed undefined]
LOG store cb put [Error: Connection closed]
LOG publish cb [Error: Connection closed undefined]
LOG store cb put [Error: Connection closed]
LOG publish cb [Error: Connection closed undefined]
LOG store cb put [Error: Connection closed]
LOG publish cb [Error: Connection closed undefined]
LOG store cb put [Error: Connection closed]
LOG publish cb [Error: Connection closed undefined]
...
LOG publish :: message `...` to topic `...`
LOG publish :: qos 1
LOG MqttClient:publish: packet cmd: publish
LOG _sendPacket :: (927d2004-8549-4345-b861-d0cb0d44dde0) :: start
LOG applyTopicAlias :: auto assign(use) topic: ... - alias: 1
LOG _sendPacket :: client not connected. Storing packet offline.
LOG _storePacket :: packet: '...'
LOG _storePacket :: cb? true