C# MqttNet library: not all retained message are received

249 Views Asked by At

I'm having a problem using MQTTnet library with retained message. I use V5 protocol, qos=2 and WithCleanStart(false).WithSessionExpiryInterval(3600).

On the server (mosquitto) max_queued_messages = 1000 (default).

Expected and tested function (no retained message, it works as I expected):

  1. Subrcriber dies
  2. Publisher sends 2000 messages
  3. Subscriber up again and receive 1000 message Perfect.

With retained message on 2000 different topic (1 message per topic) This is what I have on a third-party software (mqtt explorer):

  1. Subrcriber dies
  2. Publisher sends 2000 messages on 2000 different topic (1 message per topic)
  3. Subscriber up again and receive 2000 message Perfect.

But with MQTTnet library on my c# program I have:

  1. Subrcriber dies
  2. Publisher sends 2000 messages on 2000 different topic (1 message per topic)
  3. Subscriber up again and receive 1000-1040 message Why? It seams that it's not interest if messages are retained or not..

I suppose that there is a parameters on the MQTTnet library, I checked but I'm not able to find it. Do you have any ideas?

P.S. On not dying subsriber everithing is correct:

  1. Publisher sends 2000 messages on 2000 different topic (1 message per topic)
  2. Subscriber receive 2000 message. Perfect

in This or this is suggested a server configuration, but with a different client (mqtt explorer) everithing works correctly. So I don't think is possible a server configuration. That's why a suppose a library configuration (so.. no duplicated thread).

Mqttserver Mosquitto configuration all as defaults.

0

There are 0 best solutions below