Simple MQTT example

Demo connects to: broker.hivemq.com and in onConnect() subscribes to the topic: “testTD/myTopic”

You can use hivemq.com/demos/websocket-client/#data as a second client, just subscribe to the same topic: “testTD/myTopic”

Run the publish script to send data (in this case json) to that topic, you will get a callback onMessage() when data was sent to that topic

Run the “deleteRetained_topic” script to delete retained data from the broker. You can read up on retained data and other mqtt essentials here: hivemq.com/mqtt-essentials/
mqtt.toe (7.71 KB)

1 Like