Enhancements for the MqttPacketIdentifierProvider
- Dominant language
- C#
- Stars
- 5.1k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the feature request
The scenario is to store the messages with packet identifier for QoS>0 on the filesystem before publishing them to the MQTT Broker. Storing the messages on the filesystem helps to survive the system/mqtt client crashes.
Currently the MQTTNet does not expose any method to set the PacketIdentifier directly in the MqttApplicationMessage and the PacketIdentifier is only available in the response of PublishAsync method.
In the reconnection scenario, Due to the Reset() method from MqttPacketIdentifierProvider being called in the ConnectAsync() the packet identifier is reset to 1, if there are messages already stored in the filesystem from the last connection that will then cause the packet id conflict.
### Which project is your feature request related to?
- Client
### Describe the solution you'd like
Following are possible solutions.
1. Introducing Get property in the MqttPacketIdentifierProvider so that the current value could be read.
2. Making the call to Reset() method optional in ConnectAsync() method.
Another approach for the point 1 would be to make it possible to directly assign the packet identifier in the MqttApplicationMessage and create the interface for MqttPacketIdentifierProvider so user can provide custom packet identifier provider.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.