MQTT is thé lightweight message pub/sub mechanism for device to device communication. It is lightweight enough to be used on embedded devices.
Mosquitto is a much-used broker implementation.
Installation on MacOS
$ brew install mosquitto $ brew services start mosquitto
Quick test …
$ mosquitto_sub -t topic/state
$ mosquitto_pub -t topic/state -m "Hello World"