# MQTT Mosquitto
###### tags: `IoT over Kubernetes`
reference : [Here](https://linoxide.com/tools/setup-mosquitto-mqtt-server-ubuntu-16-04/), [Here](https://lms.onnocenter.or.id/wiki/index.php/MQTT:_install_di_Ubuntu_16.04#Setup_MQTT-Spy_dan_connnecting)
Mosquitto MQTT Server is a message broker which works over MQTT protocol. MQTT is lightweight messaging protocol that is ISO standard for use on top of TCP/IP protocol. It is mostly used for communicating with Internet of Things devices. We are going to install Mosquitto on a Ubuntu 16.04 server and we are going to send messages from MQTT-spy software. Mosquitto is an Eclipse project and it is distributed under EDL license.
## Compiling Mosquitto MQTT server from source
Installing apps dependencies:
sudo su

(Optional)
locale-gen id_ID.UTF-8
apt install build-essential libwrap0-dev libssl-dev libc-ares-dev uuid-dev xsltproc

Install finished.

adding moquitto user, because by default `mosquitto` run as non-root
adduser mosquitto

Enter password and I just assign my fullname for mosquitto (The other information could be optional)

For user mosquitto privileges add this command (aka sudo rights):
usermod -aG sudo mosquitto

So as we can see if we use this command:
su mosquitto
cd

We will come to the mosquitto bash.
Download Mosquitto source code, latest version is 1.4.9
wget https://mosquitto.org/files/source/mosquitto-1.5.gz
tar xvzf mosquitto-1.5.tar.gz
cd mosquitto-1.5/
make && sudo make install

Extract:


as the previous








Solve: https://community.openenergymonitor.org/t/mosquitto-wont-start-on-boot-after-raspbian-and-emonsd-update/5588/19

cd /usr/local/src
wget https://github.com/kamilfb/mqtt-spy/releases/download/mqtt-spy_v0.5.4/mqtt-spy-0.5.4-jar-with-dependencies.jar
#### After that, Download jdk 8 dan jre 8
Installation Here:
https://stackoverflow.com/questions/55920389/e-package-oracle-java8-installer-has-no-installation-candidate
and pick the first java 1.8 with:
sudo update-alternatives --config java
And type 0.
After java installed, we can now run the mqtt-spy:
sudo java -jar mqtt-spy-0.5.4-jar-with-dependencies.jar

## Send Messages with MQTT
Step 1: click Connections tab > new connection or CTRL + N

As we can see, we successfull to open it.
Step 2: add new IP server, for instance 192.168.1.11