You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Retained messages published with other than QOS 0 aren't received by the client upon subscription.
Which component is your bug related to?
Server
To Reproduce
See code example.
Expected behavior
Upon subscription client will received all retained messages not only ones with QOS 0.
Code example
usingSystem.Text;usingMQTTnet;usingMQTTnet.Client;usingMQTTnet.Diagnostics;usingMQTTnet.Packets;usingMQTTnet.Protocol;// prepare servervarlogger=newMqttNetEventLogger();logger.LogMessagePublished+=(_,eventArgs)=>{Console.WriteLine(eventArgs.LogMessage.Message);};varfactory=newMqttFactory(logger);varserverOptions=factory.CreateServerOptionsBuilder().WithDefaultEndpoint().Build();varmqttServer=factory.CreateMqttServer(serverOptions);awaitmqttServer.StartAsync();varclientOptions=factory.CreateClientOptionsBuilder().WithTcpServer("127.0.0.1",1883).WithCleanSession().Build();// publish retained messagevarwriteClient=factory.CreateMqttClient();awaitwriteClient.ConnectAsync(clientOptions);awaitwriteClient.PublishAsync(newMqttApplicationMessage{Topic="test_topic/0",Payload=Encoding.UTF8.GetBytes(@"{""hello"":0}"),Retain=true,QualityOfServiceLevel=MqttQualityOfServiceLevel.AtMostOnce});awaitwriteClient.PublishAsync(newMqttApplicationMessage{Topic="test_topic/1",Payload=Encoding.UTF8.GetBytes(@"{""hello"":1}"),Retain=true,QualityOfServiceLevel=MqttQualityOfServiceLevel.AtLeastOnce});awaitwriteClient.PublishAsync(newMqttApplicationMessage{Topic="test_topic/2",Payload=Encoding.UTF8.GetBytes(@"{""hello"":2}"),Retain=true,QualityOfServiceLevel=MqttQualityOfServiceLevel.ExactlyOnce});awaitwriteClient.DisconnectAsync();// create new client and subscribevarreadClient=factory.CreateMqttClient();readClient.ApplicationMessageReceivedAsync+= eventArgs =>{Console.WriteLine($"message received {eventArgs.ApplicationMessage.Topic}");returnTask.CompletedTask;};awaitreadClient.ConnectAsync(clientOptions);awaitreadClient.SubscribeAsync(newMqttTopicFilter{Topic="test_topic/+",QualityOfServiceLevel=MqttQualityOfServiceLevel.ExactlyOnce});// give it some time awaitTask.Delay(5000);awaitreadClient.DisconnectAsync();awaitmqttServer.StopAsync();
The text was updated successfully, but these errors were encountered:
Please test with version 4.0.1.184 from the MyGet feed (see Readme). I fixed the issue in this version. If it works I will release a hotfix version soon.
Describe the bug
Retained messages published with other than QOS 0 aren't received by the client upon subscription.
Which component is your bug related to?
To Reproduce
See code example.
Expected behavior
Upon subscription client will received all retained messages not only ones with QOS 0.
Code example
The text was updated successfully, but these errors were encountered: