Mosquitto

From aoxoaWiki
Jump to navigationJump to search

Notes

Just some notes for now

Eclipse Mosquitto

run broker software on a computer: say 192.168.1.33


Locally:

  mosquitto_pub -d -t msg/box -m "hello world"


Remotely - Subscribe:

  mosquitto_sub -h 192.168.1.33 -d -t msg/box


Remotely - Publish:

  mosquitto_pub -h 192.168.1.33 -d -t msg/box -m "hello from remote"


can name msg/box whatever you want (but needs to use same name to communicate with each other)

some useful info here: https://www.instructables.com/id/NodeMCU-ESP8266-Based-Switch-Board-with-Raw-TCPIP-/

also here http://www.steves-internet-guide.com/mosquitto_pub-sub-clients/

Debugging - subscribe to all channels on a server

  mosquitto_sub -v -t '#'

Debugging Connections Etc

Edit the mosquitto.conf file and set up debugging level (all for everything) and logging destinations. Then restart the mosquitto server. If you log to 'topic' then you can subscribe to the $SYS/# topic to view logging output elsewhere (not so sure about this last statement)

  vi /etc/mosquitto/mosquitto.conf
  
  log_type all
  log_dest stdout
  log_dest topic
  <save>

  mosquitto -c /etc/mosquitto/mosquitto.conf &

Install Mosquitto on Raspberry Pi

reference: https://www.switchdoc.com/2018/02/tutorial-installing-and-testing-mosquitto-mqtt-on-raspberry-pi/

  sudo wget https://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
  sudo apt-key add mosquitto-repo.gpg.key
  cd /etc/apt/sources.list.d/
  sudo wget http://repo.mosquitto.org/debian/mosquitto-stretch.list
  sudo apt-get update
  sudo apt-get install mosquitto mosquitto-clients
  sudo /etc/init.d/mosquitto stop

If we are going to link C or C++ code to Mosquitto, we need the development libraries

  sudo apt-get install libmosquitto-dev libmosquittopp-dev



Back to Main Page . .