ApplicationMessageProcessed event is not firing in managed MQTTnet client

匿名 (未验证) 提交于 2019-12-03 01:26:01

问题:

MQTTnet is a high performance .NET library for MQTT based communication.

This is GitHub Link. https://github.com/chkr1011/MQTTnet . It provides a MQTT client and a MQTT server (broker). The implementation is based on the documentation from http://mqtt.org/.

This is how I have created managed MQTT client. Here is the link https://github.com/chkr1011/MQTTnet/wiki/ManagedClient

    // Setup and start a managed MQTT client.     var options = new ManagedMqttClientOptionsBuilder()      .WithAutoReconnectDelay(TimeSpan.FromSeconds(5))      .WithClientOptions(new MqttClientOptionsBuilder()      .WithClientId("Client1")      .WithTcpServer("broker.hivemq.com")      .WithTls().Build())      .Build();       this.mqttClient = new MqttFactory().CreateManagedMqttClient(new MqttNetLogger("IDMQTTManagedPublisher"));     await this.mqttClient.SubscribeAsync(new TopicFilterBuilder().WithTopic("RequestTopic").Build());     SubscribeToApplicationMessageReceived();     await this.mqttClient.StartAsync(options);

Subscription to ApplicationMessageProcessed event

  private void SubscribeToApplicationMessageProcessed()   {     this.mqttClient.ApplicationMessageProcessed += (s, e) =>     {       };   }

Message sending code

      var messagePayload = new MqttApplicationMessageBuilder()         .WithTopic("RequestTopic")         .WithPayload(message)         .WithExactlyOnceQoS()         .WithRetainFlag()         .Build();          await mqttClient.PublishAsync(messagePayload);

But ApplicationMessageProcessed event is not firing in managed MQTTnet client

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!