Now I will show you how to develop a simple MQTT broker that can accept all clients and display messages received from clients. So let’s start with the definition of MQTT Broker and follow the steps below.

What is MQTT Broker?
According to Wikipedia: An MQTT broker is computer-based software (running on-premises or in the cloud) and can be self-built or hosted by a third party. It is available in both open source and proprietary implementations. The broker acts like a post office, MQTT doesn’t use the intended recipient’s address but uses a subject line named “Subject” and anyone who wants a copy of that message will subscribe to the master. that topic. Multiple clients can receive messages from a single broker (one to many possibilities). Similarly, multiple publishers can publish topics to a single subscriber (multiple subscribers). Each client can create and receive data by publishing and subscribing, i.e. devices can publish sensor data and still receive configuration information or control commands (MQTT is a communication protocol). bidirectional communication). This helps in both data sharing, device management and control.
Simple code with MQTT Broker
1.Install References
ou go to NuGet Package Manager of Project References. Search for some MQTTNet, Serilog, System.Text.Json settings as below.



2.Implementation
You insert this code into program.cs.

Use and default port 1883.
You can now test the MQTT Explorer and MQTT Broker apps

In this post, We see how it is possible to develop an MQTT Broker. I hope it is useful to you.
If you’re still unsure or have questions about what to do or if you get any errors, then I suggest you use the comments section below and let me know! I’m here to help






