What you’ll need
- An ngrok account.
- The ngrok agent installed.
- MQTT Explorer installed.
- The Mosquitto binary installed.
Start an MQTT server
This guide uses Eclipse Mosquitto as the MQTT server.
Follow the Mosquitto download and install instructions for your operating system, then start the server:Mosquitto listens on port
1883 by default and starts in local-only mode, so connections are only possible from the same machine until you expose it.
For listener and authentication options, see the Mosquitto documentation.Launch ngrok
With your MQTT server running on Start a TCP endpoint that forwards to Mosquitto’s port:ngrok displays a
localhost, put it online with an ngrok TCP endpoint.If you haven’t already, add your authtoken from the ngrok dashboard:tcp:// forwarding address where your server is exposed to the internet.
Copy this address for use with MQTT Explorer.Connect with MQTT Explorer
Open MQTT Explorer and click the plus sign to create a new MQTT connection.
Enter the TCP address from the last step and click Connect.You’ll see a few new lines in your MQTT server logs:MQTT Explorer is now connected to your server over the public internet.
To get messages from the client, subscribe to a topic.
In your terminal, open a tab and enter:Back in MQTT Explorer, publish a message to
example/topic.You’ll see the message in the terminal tab where you subscribed to the topic: