5

I have linux server running with public ip. I have set up mosquitto broker with the following commands.

apt-get install mosquitto
apt-get install libmosquitto-dev
apt-get install mosquitto-clients

My broker is running in linux server.I am listening on port 1883. It is working fine when I try to run this in the server with the following commands.

mosquitto_sub -h localhost -t "mqtt" -v
mosquitto_pub -h localhost -t "mqtt" -m "Testing"

But it is not working from outside when I try to access this broker from home network. I am trying MQTTlens as a tool to test the broker.

1 Answers1

2

If I am not wrong in understanding you question, You are trying to connect to the broker via a device which is not on the same network as the broker is.

If that's the case then the thing is that MQTT broker is present only in your private network and it's not public even if you know the public IP as the public IP address is handled by NAT on your router.

To make your broker public, you need to forward the port 1883 in your router so that any requests on that port be forwarded to the device that is running your broker. You can check online on how to port forward on your specific router model.

Tl;dr forward the port you are listening on your router and then use public ip to connect.