How to use MQTT over the internet?

Jorn.Beyers picture Jorn.Beyers · Mar 9, 2015 · Viewed 30.5k times · Source

Currently, I'm successfully running a mosquitto broker, subscribing to topics and publishing messages with clients in a local network.

How can I communicate with another local network which is located at a different IP address?

Should I set up 2 mosquitto brokers, one for each local network?

Answer

ppatierno picture ppatierno · Mar 9, 2015

The PC in the other local network needs to be accessible from Internet, so if it is behind a firewall, you need to set a port forwarding rule inside your router. The rule needs to forward the traffic from the public IP address to the internal LAN private IP address of your broker.

Remember that MQTT uses ports 1883 and 8883 (for SSL).