MQTTnet icon indicating copy to clipboard operation
MQTTnet copied to clipboard

Client side delivery guarantee (QoS 1 or 2)

Open yuridiniz opened this issue 7 years ago • 11 comments

Steps:

1 - Connect to Broker 2 - Subscribe to the topic "test/" 2 - Disconnect the client 3 - Send a message to a topic "test/" with QoS 1 or 2 4 - Close the application 5 - Open the application 6 - Connect to Broker

Result:

Messages sent with QoS 1 and 2 will be lost

Expected results

Resend messages after restarting the application using MQTT only

By MQTT protocol specification, when using QoS 1 or 2, you are guaranteed that the message arrives in the broker, but if the client is offline and restart the application, the message will be loss

Using ManagedClient I will have the guarantee that the message will be delivered, but it has some limitations like CleanSession = false, so I can not guarantee that QoS 1 or 2 will reach me

It seems to me that the QoS 1 and 2 delivery guarantee defined in the MQTT protocol is not being met.

Is there any plan for this?

yuridiniz avatar Jul 23 '18 20:07 yuridiniz

If I understand you correct, you need to add a implementation of IManagedMqttClientStorage to ManagedMqttClientOptions.Storage.

You can look at a simple implementation from the tests, https://github.com/chkr1011/MQTTnet/blob/15d4ee4d68ef7191aab756707717eacf36ee31e0/Tests/MQTTnet.TestApp.NetCore/ManagedClientTest.cs#L75-L101

jenscski avatar Jul 24 '18 06:07 jenscski

Thanks, I had implemented this example to look at the operation of ManagedClient, the problem of ManagedClient is that it does not allow session usage, so messages sent by other clients with QoS 1 or 2 will not be received by offline clients

yuridiniz avatar Jul 24 '18 12:07 yuridiniz

Support for sessions in ManagedClient is planned but not yet completed. I assume it will be implemented in 2.9.0.

chkr1011 avatar Jul 24 '18 21:07 chkr1011

What's the status of this @chkr1011?

SeppPenner avatar Jun 28 '19 16:06 SeppPenner

@chkr1011 please any update on offline session support for managed client?

MarekLani avatar Dec 03 '19 08:12 MarekLani

The storage on the managed client can't work as a workaround for QoS for two reasons:

  1. interoperating with other system
  2. can't choose the reliability feature on a per-message basis. Currently you need one "reliable/storage-enabled" client and another one without storage.

While I can "hack" the storage class to overcome the second problem, it is not a clean solution. For this reason I am switching to a mix of MQTT and REST, which raise the complexity of the entire solution.

Hope to see this implemented soon. Thanks for the efforts

raffaeler avatar Nov 02 '20 11:11 raffaeler

@chkr1011 Does managed client support sessions? I searched in the release notes on session but I couldn't find any related items.

ramonsmits avatar May 03 '21 21:05 ramonsmits

No the managed client does not yet support sessions.

chkr1011 avatar Jan 27 '22 19:01 chkr1011

@chkr1011 Could you please clarify what is the "close issue" related to? The thread was about client-side guarantee (QoS of the specs). Will the library provide this or not? Thanks!

raffaeler avatar Jan 27 '22 20:01 raffaeler

Ah that was a mistake. This feature will be added as soon as there is time for it. As long as this is not implemented I recommend to use the regular client and doing the storage of the application messages manually.

chkr1011 avatar Jan 27 '22 20:01 chkr1011

As long as this is not implemented I recommend to use the regular client and doing the storage of the application messages manually.

This suggests the issue is on the client side.

6 - Connect to Broker

If this step happens with CleanSession = false and the same same ClientId, the broker should send back the messages that it stored for that session.

If it doesn't, that is an issue with the broker.

tmds avatar Jun 15 '23 07:06 tmds