This article provides a step-by-step guide for installing and configuring the Mosquitto MQTT broker on a Robustel EG series gateway (e.g., EG5120, EG5200) running RobustOS Pro. This setup is ideal for scenarios where you need a reliable, local messaging hub for your IoT devices, such as sensors, actuators, and other smart equipment.
By hosting the broker directly on the gateway, you create a robust and low-latency communication system that can operate independently of cloud services, enhancing the speed and reliability of your local network.
Hardware List:
Software/Firmware:
Other:
The entire process is broken down into three main stages: connecting to the gateway, installing the software, and configuring the broker.
Connect to the gateway using your sudo username. The default IP address is 192.168.0.1.
ssh your_sudo_username@192.168.0.1sudo apt updateThis command may ask for your password. Enter the password for your sudo user to continue.
sudo apt install mosquitto mosquitto-clients -ysudo systemctl status mosquittoYou should see an "active (running)" status, as shown below.
By default, Mosquitto only allows connections from the gateway itself. For testing, we will modify the configuration to allow connections from any device on the local network.
vi text editor:sudo vi /etc/mosquitto/mosquitto.conflistener 1883 0.0.0.0
allow_anonymous true
Esc, then :wq, and then Enter.sudo systemctl restart mosquittoSECURITY WARNING: The configuration above uses allow_anonymous true, which is suitable ONLY for initial setup, testing, and trusted local networks. For a production environment, this is highly insecure.
For production, you must disable anonymous access and implement a proper authentication and authorization strategy. This includes setting up user/password files and configuring Access Control Lists (ACLs) to restrict which users can publish or subscribe to specific topics.
We strongly recommend you follow the official Mosquitto documentation to properly secure your broker.
Before starting the tests, it's crucial to verify that the Mosquitto service is running correctly after all the configuration changes. Connect via SSH and run:
sudo systemctl status mosquittoYou must see an active (running) status. If it is not active, review the previous steps for errors and try restarting it with sudo systemctl restart mosquitto.
This test confirms the broker is running correctly on the gateway itself.
mosquitto_sub to subscribe to a test topic. It will wait for messages.mosquitto_sub -t "robustel/test" -vmosquitto_pub to publish a message to that topic:mosquitto_pub -t "robustel/test" -m "Hello from local test"robustel/test Hello from local testThis test confirms that other devices on the same local network (LAN) can connect to the broker. Perform this test only if you need to allow other devices on the network to communicate with the broker.
Note on Remote (WAN) Access: This test is for the local internal network. By default, this traffic is allowed. If you need to access your MQTT broker from the external network (WAN/Internet), you must configure a firewall rule to allow this traffic. For instructions, please see How to open a firewall port on an EG series gateway.
192.168.0.1).1883Username and Password blank (as we allowed anonymous connections for testing).robustel/test/message and click Subscribe.robustel/test/message) and type a message (e.g., "Hello from Robustel Gateway").Q: The apt install mosquitto command fails.
A: This command requires an internet connection.
Internet Status widget on the System Status -> Overview page.wwan) and a valid IP address.Q: My MQTT client (from the LAN) cannot connect.
A: This is the most common issue. Check the following in order:
sudo systemctl status mosquitto. Ensure it is "active (running)"./etc/mosquitto/mosquitto.conf file. Using listener 1883 0.0.0.0 makes the broker accessible from all network interfaces on the gateway. If you did not configure it this way, you must ensure the service is listening on an IP and port that your client can reach. For example, binding to the gateway's LAN IP (e.g., listener 1883 192.168.0.1) will prevent WAN devices from accessing it. Binding to the WAN IP will prevent LAN devices from accessing it. Always ensure your client is connecting to the correct IP and port that you have configured in this file.allow_anonymous true is in the config file. If you set up passwords (as per the Production warning), you must provide the correct username and password in your client.internal zone) access. If you are trying to connect from the LAN, check your client's IP and the gateway's IP. If you are trying to connect from the WAN (firewall external zone), you must add a specific firewall rule as noted in the "Optional: Test from a LAN Client" section.Revision  | Date  | Author  | Notes  | 
1.0  | 2025-09-27  | Jens Zhou  | Initial Release  |