About Mosca…

Mosca is a node.js mqtt broker, which can be used:

  • STANDALONE
  • Embaded in another node.js application

Features

  • MQTT 3.1 and 3.1.1 compliant.
  • QoS 0 and QoS 1.
  • Various storage options for QoS 1 offline packets, and subscriptions.
  • Usable inside ANY other Node.js app.
  • version 2.0.0+ targets node v6, v4 and v0.12
  • version 1.0.0+ targets node v6, v5, v4 and v0.12, with partial support for node v0.10.

Manual Static Analysis Tool Language Support

Languages it can scan for vulnerabilities are:

  • ASP
  • C
  • C#
  • Java
  • JavaScript
  • PHP
  • Ruby
  • Swift

You can download Mosca here:

Mosca-master.zip

How to use…

  • FOR STANDALONE
npm install mosca pino -g
mosca -v | pino
  • FOR EMBEDDED
npm install mosca --save

CODE

var mosca = require('mosca');

var ascoltatore = {
  //using ascoltatore
  type: 'mongo',
  url: 'mongodb://localhost:27017/mqtt',
  pubsubCollection: 'ascoltatori',
  mongo: {}
};

var settings = {
  port: 1883,
  backend: ascoltatore
};

var server = new mosca.Server(settings);

server.on('clientConnected', function(client) {
    console.log('client connected', client.id);
});

// fired when a message is received
server.on('published', function(packet, client) {
  console.log('Published', packet.payload);
});

server.on('ready', setup);

// fired when the mqtt server is ready
function setup() {
  console.log('Mosca server is up and running');
}

CREDITS…

Matteo Collina

LEAVE A REPLY

Please enter your comment!
Please enter your name here