MQTTnet icon indicating copy to clipboard operation
MQTTnet copied to clipboard

Retained message is not removed after expiry interval expired

Open Do4bled opened this issue 2 years ago • 6 comments

Describe the bug

When publishing on a topic using the .WithRetainFlag(true) option and setting the MessageExpiryInterval to x seconds the message is pushed to the server. There it stays in the topic until it gets overwritten with a new message or it will be removed because a new message is send without any payload. According to the documentation the message should be deleted from the topic after the x seconds specified in the publish call which is not the case.

To make sure it was not client related I used the mosquitto test Server to verify, and indeed there the message was removed after the x seconds passed.

Which component is your bug related to?

  • Server

To Reproduce

Steps to reproduce the behavior: Using this version of MQTTnet '4.0.1.184'. and select version 5 of MQTT. Create a simple version of the Server using the MQTTnet nuget Create a simple version of an publishing client using MQTTnet that publish a message using the above mentioned flags Create a simple version of an subscribing client using MQTTnet As a alternative the Mosquitto_pub and Mosquitto_sub commandline tools can be used as clients.

Expected behavior

the message will be removed from the topic after the x seconds are passed as described in the documentation here: https://www.hivemq.com/blog/mqtt5-essentials-part4-session-and-message-expiry/

Do4bled avatar Jun 17 '22 11:06 Do4bled

According to "https://github.com/dotnet/MQTTnet/wiki/MQTT-Version-5-Features" This is not yet supported. It is planned but not yet started.

chkr1011 avatar Jun 17 '22 14:06 chkr1011

That is a shame, I missed that part in the wiki. Is there an expected delivery date for it?

Do4bled avatar Jun 17 '22 17:06 Do4bled

Currently stabilizing version 4.0 by fixing issues has priority. After that new features will be added with version 4.1. The expiry of retained messages is quite simple to implement so that I assume it will be implemented within 1-3 month. Hope this helps.

chkr1011 avatar Jun 18 '22 08:06 chkr1011

@chkr1011 What is the status here?

Int32Overflow avatar Jan 30 '23 10:01 Int32Overflow

Hi @chkr1011,

Is there any good news?

onurcanyilmaz avatar Feb 21 '23 21:02 onurcanyilmaz

No update here. We are still working on making the retained messages manager a component which can be replaced with other implementations. This also raises the question which component is now responsible for cleaning up the retained messages. I will let you know when there are updates.

chkr1011 avatar Feb 22 '23 20:02 chkr1011