About Mosca…

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

  • Embaded in another node.js application


  • 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:


How to use…

npm install mosca pino -g
mosca -v | pino
npm install mosca --save


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');


Matteo Collina

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *