ManagedClient WithCleanSession
See original GitHub issueI’m trying to use the clean session with the managed client
var options = new ManagedMqttClientOptionsBuilder()
.WithAutoReconnectDelay(TimeSpan.FromSeconds(5))
.WithClientOptions(new MqttClientOptionsBuilder()
.WithClientId(Guid.NewGuid().ToString())
.WithTcpServer(configuracion.Servidor)
.WithCredentials(configuracion.Username, configuracion.Password)
.WithKeepAlivePeriod(TimeSpan.FromSeconds(60))
.WithCleanSession(false) //sesion persistente
.Build())
.Build();
var mqttClient = new MqttFactory().CreateManagedMqttClient();
await mqttClient.SubscribeAsync(new TopicFilterBuilder()
.WithTopic(configuracion.Topic)
.WithExactlyOnceQoS()
.Build());
await mqttClient.StartAsync(options);
I have tried to connect to 2 different HiveMQ brokers with the following error:
Error: System.NotSupportedException: The managed client does not support existing sessions.
at MQTTnet.Extensions.ManagedClient.ManagedMqttClient.StartAsync(IManagedMqttClientOptions options)
at MQTT_client.MQTT.ManageMQTTClient()
If I use other client, I can connect successfully using cleansesion to that HiveMQ broker.
So, is it not supported to use cleansession with managed client? or it could be done in a different way using the managed client?
I’m using the 3.0.2 MQTTnet version
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
ManagedClient WithCleanSession · Issue #687
I'm trying to use the clean session with the managed client var options = new ManagedMqttClientOptionsBuilder() .
Read more >ManagedClient Memory Leak - Apple Community
ManagedClient is increasing 400-500 MB of RAM usage per hour until it reaches many GB in size and the machine starts to suffer....
Read more >Unable to add a client certificate in MqttNet Managed Client
getting a little problem I'm unable to add certificate with client. it is giving me error of type mismatch. this is my code....
Read more >MQTT Publishing and Subscribing Messages to ...
I will be using CloudMQTT MQTT Broker Free Instance for this article. Add "MQTTnet.Extensions.ManagedClient" Nuget Package. The Latest DZone ...
Read more >C# Demo Usage Guide - 华为云
ManagedClient v3.0.11 is an extension library that uses MQTTnet to provide additional functions for the ... WithCleanSession(false) .
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

No that is not supported yet but already on the feature list.
No not yet. Also will this feature come with some drawbacks because it cannot cover all use cases. But you can always use the regular MqttClient. The ManagedMqttClient is just a small extension which reconnects automatically etc. With that base client you can do everything (including reuse of existing sessions).