This is what I want to do:
I want to connect my client using MQTT
to Node.JS server
and then from there(Node.JS Server) I want to handle all pub/sub. When client publishes any message, it will go to Node.JS server
and from there it will be sent to RabbitMQ
and reverse for the subscriber.
Flow is like :-
MQTT -> Node.JS -> RabbitMQ.
mosca
home page. I added few lines for RabbitMQ
connections. var mosca = require('mosca')
var pubsubsettings = {
type: 'mqtt',
json: false,
mqtt: require('mqtt'),
host: '127.0.0.1',
port: 1883
};
var settings = {
port: 1883,
backend: pubsubsettings
};
var server = new mosca.Server(settings);
server.on('ready', setup);
function setup() {
console.log('Mosca server is up and running')
}
server.on('clientConnected', function (client) {
console.log('client connected', client.id);
});
server.on('published', function (packet, client) {
console.log('Published : ', packet.payload);
});
server.on('subscribed', function (topic, client) {
console.log('subscribed : ', topic);
});
// fired when a client subscribes to a topic
server.on('unsubscribed', function (topic, client) {
console.log('unsubscribed : ', topic);
});
server.on('clientDisconnecting', function (client) {
console.log('clientDisconnecting : ', client.id);
});
server.on('clientDisconnected', function (client) {
console.log('clientDisconnected : ', client.id);
});
Now I want to create a client that can connect to this Node.JS
server. But I am not able to figure out the way to connect.
Rabbit supports MQTT directly.
https://www.rabbitmq.com/mqtt.html
Paul