0

I'm very new to MQTT, but have been using .Net for years. I have an existing process that gets data and sends commands to an external device. But I have a new customer that wants that data to be sent to their process using MQTT. I understand the basic MQTT protocol, but I'm trying to implement it in .Net. Here is my setup:

enter image description here

The communication between my Broker and the device is well-established. But I'm trying to understand the implementation of MQTT in the broker so that it can both receive commands from the application, and publish data to the application. There are only a few implementations of MQTT in .net out there, and from what I've found, they use older versions of MQTT, not 5.0 and the samples from MQTTnet on Github are a little confusing.

So my questions are:

  1. Is it true that I need to create both an mqtt client and an mqtt server in the Broker for this implementation?
  2. In the Client code, can I create a single client once and keep it as a local variable or do I need to dispose of it?
  3. What is the correct event to register on the client to get published messages - is it ApplicationMessageReceivedAsync?
Alexa Kirk
  • 152
  • 10
  • I think you are on a slightly wrong path. I don't think you need a mqtt broker, your customer most likely has their own. You just need a client, that subscribes to "commands" and publishes to "data". You can use a single MqttNet ManagedClient for this. – Jeanot Zubler Aug 10 '23 at 05:27
  • Thanks! You're probably right, I didn't think about that. I will get clarification. – Alexa Kirk Aug 10 '23 at 12:14

0 Answers0