A Reactive Client for MQTTnet Broker
NOTE: ManagedClient support has been removed from the MQTTnet.Rx.Client library. This is due to the fact that the ManagedClient is no longer included in the MQTTnet V5 library.
We now have a Reactive implimentaion through IResilientClient that we aim to have feature parity with the ManagedClient.
The ResilientClient is a wrapper around the MqttClient that will automatically reconnect to the broker if the connection is lost.
Create.ResilientMqttClient()
.WithResilientClientOptions(a =>
a.WithAutoReconnectDelay(TimeSpan.FromSeconds(5))
.WithClientOptions(c =>
c.WithTcpServer("localhost", 9000)))
.PublishMessage(_message)
.Subscribe(r => Console.WriteLine($"{r.ReasonCode} [{r.PacketIdentifier}]"));
Create.ResilientMqttClient()
.WithResilientClientOptions(a =>
a.WithAutoReconnectDelay(TimeSpan.FromSeconds(5))
.WithClientOptions(c =>
c.WithTcpServer("localhost", 9000)))
.SubscribeToTopic("FromMilliseconds")
.Subscribe(r => Console.WriteLine($"{r.ReasonCode} [{r.ApplicationMessage.Topic}] value : {r.ApplicationMessage.ConvertPayloadToString()}"));
Create.MqttClient()
.WithClientOptions(a => a.WithTcpServer("localhost", 9000))
.PublishMessage(_message)
.Subscribe(r => Console.WriteLine($"{r.ReasonCode} [{r.PacketIdentifier}]"));
Create.MqttClient()
.WithClientOptions(a => a.WithTcpServer("localhost", 9000))
.SubscribeToTopic("FromMilliseconds")
.Subscribe(r => Console.WriteLine($"{r.ReasonCode} [{r.ApplicationMessage.Topic}] value : {r.ApplicationMessage.ConvertPayloadToString()}"));
A Reactive Server for MQTTnet Broker
Create.MqttServer(builder =>
builder
.WithDefaultEndpointPort(2883)
.WithDefaultEndpoint()
.Build())
.Subscribe();