Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancements for the MqttPacketIdentifierProvider #2064

Open
Nukta101 opened this issue Aug 15, 2024 · 2 comments
Open

Enhancements for the MqttPacketIdentifierProvider #2064

Nukta101 opened this issue Aug 15, 2024 · 2 comments
Labels
feature-request New feature or request

Comments

@Nukta101
Copy link

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.

@Nukta101 Nukta101 added the feature-request New feature or request label Aug 15, 2024
@chkr1011
Copy link
Collaborator

I prefer to expose the packet identifier in the MqttApplicationMessage. If it is left 0 a new one will be created using the identifier provider. Additionally, I will add a new parameter to the client options which allows to setup the offset of the identifier values when connecting with the server. The client will also get a new property which exposes (read only) the latest used packet identifier so that you can store it after disconnecting and reuse it when connecting. What do you think?

@Nukta101
Copy link
Author

Yes, that covers the use case. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants