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
I am using ManagedMqttClient and after start, I am subscribing to a topic (foo/+)
some other mqtt clients are publishing retained messages to topic foo/bar1, foo/bar2, etc...
I have the following code:
var foobars = new List<string>();
var mqttClient = mqttFactory.CreateManagedMqttClient();
var mqttClientOptions = new MqttClientOptionsBuilder()
.WithTcpServer("127.0.0.1", 1883)
.Build();
var managedMqttClientOptions = new ManagedMqttClientOptionsBuilder()
.WithClientOptions(mqttClientOptions)
.WithAutoReconnectDelay(new TimeSpan(0, 0, 5))
.Build();
await mqttClient.StartAsync(managedMqttClientOptions).ConfigureAwait(false);
mqttClient.ApplicationMessageReceivedAsync += args =>
{
foobars.Add(args.ApplicationMessage.Topic);
return Task.CompletedTask;
};
await mqttClient.SubscribeAsync("foo/+").ConfigureAwait(false)
await Task.Delay(1000).ConfigureAwait(false);
Console.WriteLine(foobars.Count);
So is there a way to remove the call to Task.Delay(1000) and knowing that all retained messages are received ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello all,
I am using ManagedMqttClient and after start, I am subscribing to a topic (foo/+)
some other mqtt clients are publishing retained messages to topic foo/bar1, foo/bar2, etc...
I have the following code:
So is there a way to remove the call to Task.Delay(1000) and knowing that all retained messages are received ?
Beta Was this translation helpful? Give feedback.
All reactions