MQTT introduction

mqtt

MQTT BROKER

Installation and Configuration

0 – State of the art – protocol
-> here

1 – Downloads:

-> mosquitto: https://mosquitto.org/download/

-> win32 OpenSSL : http://slproweb.com/products/Win32OpenSSL.html (compatible with x64 version)

->pthreads-win32 : ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/dll/x86/ (or 64 version) – direct url

2 – Install win32 OpenSSL 

3 – Install mosquitto (MQTT)

4 – Unzip and copy pthreads files (x86 or x64 – try x86 if x64 not work)

-> Required DLLs: copy pthreadVC2.dll and past on mosquitto folder.

-> Required DLLs: copy libeay32.dll and ssleay32.dll (Look for these files in the OpenSSL-Win32 or OpenSSL-Win32\Bin folder) and past on mosquitto folder.

5- Open “command prompt” as administrator 

-> Go to mosquitto folder (or add to windows PATH):

cd "C:\Program Files (x86)\mosquitto"

5.1 – Test mosquitto service:

mosquitto.exe

-> Open new cmd and write “netstat -na”, and search “0.0.0.1:1883”, “127.0.0.1:1883” and “192.168.XX.XX:1883” -> It’s all ok if this happens.

netstat -na

5.2 – Change configuration file to require password:

-> Open: mosquitto.conf (in mosquitto folder) and uncomment:

allow_anonymous false
password_file "‪C:\Program Files (x86)\mosquitto\pwfile"

Press save.

5.3 – Create pwFile (user and passwords)

-> Open new cmd as admin, go to mosquitto folder and write:

mosquitto_passwd -c "C:\Program Files (x86)\mosquitto\pwfile" youruser
enter password

5.4 – Start mosquitto service with configuration file:

mosquitto.exe -c "C:\Program Files (x86)\mosquitto\mosquitto.conf" -v

6- Run SUBSCRIVER:

Open new cmd and write:

mosquitto_sub -h 127.0.0.1 -u YOURUSER -P YOURPASSWORD-p 1883 -t "#"
 (#-> listen all)

6- Run PUBLISHER:

Open new cmd and write:

mosquitto_pub -h 127.0.0.1 -u YOURUSER -P YOURPASSWORD -p 1883 -t "test" -m "ok"

pub

RESULT:

ok

Test BROKER with chrome Extention: MQTTLens

mqttlens

Anúncios

Deixe uma Resposta

Preencha os seus detalhes abaixo ou clique num ícone para iniciar sessão:

Logótipo da WordPress.com

Está a comentar usando a sua conta WordPress.com Terminar Sessão / Alterar )

Imagem do Twitter

Está a comentar usando a sua conta Twitter Terminar Sessão / Alterar )

Facebook photo

Está a comentar usando a sua conta Facebook Terminar Sessão / Alterar )

Google+ photo

Está a comentar usando a sua conta Google+ Terminar Sessão / Alterar )

Connecting to %s