-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
I connect to my broker and subscribe to a topic where there is a retained message.
I expect to receive the message immediately.
But nothing happens.
public async Task<string> Get(string topic)
{
using (IMqttClient mqttClient = _MqttClientFactory.CreateMqttClient())
{
MqttClientOptions mqttClientOptions = new MqttClientOptionsBuilder().WithTcpServer(_Options.Host).Build();
MqttClientConnectResult rc = await mqttClient.ConnectAsync(mqttClientOptions);
mqttClient.ApplicationMessageReceivedAsync += MqttClient_ApplicationMessageReceivedAsync;
MqttClientSubscribeOptions mqttSubscribeOptions = _MqttClientFactory.CreateSubscribeOptionsBuilder()
.WithTopicFilter("zigbee2mqtt/Home/Hall/Thermostat")
.Build();
MqttClientSubscribeResult rs = await mqttClient.SubscribeAsync(mqttSubscribeOptions);
await Task.Delay(80000);
}
return string.Empty;
}
private async Task MqttClient_ApplicationMessageReceivedAsync(MqttApplicationMessageReceivedEventArgs arg)
{
_Logger.LogDebug(arg.ToString());
string payload = Encoding.UTF8.GetString(arg.ApplicationMessage.Payload);
await Task.CompletedTask;
}
How do I get the message and return it to the caller?
Metadata
Metadata
Assignees
Labels
No labels