Running Mosquitto MQTT Broker on a Windows 10 Machine: Configuring Mosquitto
Mosquitto is a popular open-source MQTT broker that is easy to set up and use. In this article, we will cover the steps to configure Mosquitto on a Windows 10 machine, including how to forward the default port (1883) to use a public IP address.
Prerequisites
Before we begin, make sure you have the following:
- A Windows 10 machine
- Mosquitto MQTT broker installed
Configuring Mosquitto
To configure Mosquitto, you need to edit the configuration file (mosquitto.conf). Here are the steps:
- Open the configuration file in a text editor. The default location is
C:\ProgramData\Mosquitto. - Add the following lines to the file:
listener 1883 listener 9001 protocol mqtt address:1883 - Save and close the file.
The first listener line sets the default port (1883) for local connections. The second listener line sets a new port (9001) for remote connections. The protocol line specifies the MQTT protocol. The address line specifies the public IP address and port to use for remote connections.
Forwarding the Port
To forward the default port (1883) to use a public IP address, you need to use a port forwarding tool. Here are the steps:
- Open your router's configuration page.
- Find the port forwarding section.
- Add a new rule with the following settings:
- Service name: Mosquitto
- Protocol: TCP
- External port: 1883
- Internal port: 1883
- Internal IP address: The IP address of your Windows 10 machine
- Save and close the page.
Testing the Configuration
To test the configuration, you can use a MQTT client such as MQTT.fx. Here are the steps:
- Open MQTT.fx.
- Connect to the broker using the following settings:
- Host: The public IP address
- Port: 1883
- Protocol: MQTT
- Publish a message to a topic.
- Subscribe to the topic to receive the message.
In this article, we covered the steps to configure Mosquitto MQTT broker on a Windows 10 machine, including how to forward the default port (1883) to use a public IP address. We also covered how to test the configuration using a MQTT client.
References
--end article--