IOT Mosquitto mqtt how to test on localhost -


i'm playing around mosquitto ans mqtt protocol following video https://www.youtube.com/watch?feature=player_embedded&v=we7gvifrv7q

trying test on localhost

in terminal window run :

mosquitto_sub -t "nodeconf/eu" -v 

but when run snippet:

var mqtt    = require('mqtt'); var client  = mqtt.connect();  client.on('connect', function () {   client.subscribe('nodeconf/eu');   client.publish('nodeconf/eu','hello'); });   client.on('message', function (topic, message) {   // message buffer    console.log(message.tostring());   client.end(); }); 

i don't see (in terminal window) hello.

what's wrong, please ?

btw i'm looking tutorial , guide on topic thanks.

you have add console.log second (the javascript) client see why doesn't publishes hello properly.

but can typical test mosquitto clients:

1) subscribing topic:

mosquitto_sub -d -h localhost -p 1883 -t "myfirst/test"

2) other client publishes message content topic:

mosquitto_pub -d -h localhost -p 1883 -t "myfirst/test" -m "hello"

3) subscribed clients topic automatically message.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -