MQTTnet icon indicating copy to clipboard operation
MQTTnet copied to clipboard

ManagedMqttClient.PublishAsync unstable when using Queueing

Open LouisCPro opened this issue 4 years ago • 5 comments

Describe the bug

if I use the simple Task.PublishAsync that enqueue my publish, it does never send it. If I use the other prototype that takes MqttApplicationMessageBuilder message (not the queued one), and returns MqttClientPublishResult, then it apparently does not use the queueing system, and send instantly my publication to the broker.

Do I need to manage other properties of the Managed Implementation to ensure some king of 'performance' in the Managed Queue version of the publish ?

Which project is your bug related to?

  • ManagedClient

To Reproduce

Steps to reproduce the behavior: MQTTNet version is 3.0.13

When using this code :

                private IManagedMqttClient m_mqttclient = null;
                ....
                var message =  new MqttApplicationMessageBuilder()
                        .WithTopic(topic)
                        .WithPayload(payload)
                        .WithRetainFlag(false)
                        .Build();

                MqttClientPublishResult _result = await m_mqttclient.PublishAsync(message, CancellationToken.None);

Publish is done Well.

But when using :

            var message = new ManagedMqttApplicationMessageBuilder()
                        .WithApplicationMessage(new MqttApplicationMessageBuilder()
                            .WithTopic(topic)
                            .WithPayload(payload)
                            .WithRetainFlag(false)
                            .Build())
                        .Build();

            await m_mqttclient.PublishAsync(message);

Nothing Appends. Message seems to b queued but not received by the Mqtt Broker...

Expected behavior

Queue should be parsed at a time, to dequeue and effectively push messages to the Broker, but.....

LouisCPro avatar Jan 08 '21 16:01 LouisCPro

Basically Publish with a regular application message is just an overload for the managed mqtt application message version of the method.

The managed client works fully autonomous and has an internal queueing mechanism so it will always return without even sending the message.

chkr1011 avatar Jan 13 '21 17:01 chkr1011

@chkr1011

Thanks for the feedback. Of course I understand well that in case of queueing, the send process is done background and potentially with delay, but when I say it does not send anything, it is not only on return, but even after a couple of minutes !

Knowing that the client has not so much things to do after the publish, it should be a couple of seconds.

LouisCPro avatar Jan 14 '21 07:01 LouisCPro

@LouisCPro Sounds strange to me. Could you please try the regular MQTTClient? I only want to know whether that client performs better than the managed one.

chkr1011 avatar Jan 14 '21 19:01 chkr1011

@chkr1011

With the regular MqttClient, no problem !

LouisCPro avatar Jan 15 '21 08:01 LouisCPro

That sounds really strange to me. I will have a look.

chkr1011 avatar Jan 23 '21 09:01 chkr1011