moscajs / mosca

MQTT broker as a module
mosca.io
3.2k stars 513 forks source link

Illegal instruction (core dumped) #745

Open cloudswave opened 6 years ago

cloudswave commented 6 years ago

I want to have a stress test. the client publish message /100ms, but the server crash and has the log Illegal instruction (core dumped) . the server code :

var mosca = require('mosca');
var tag = "mqtt-server";
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(tag,'client connected', client.id);
});

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

server.on('ready', setup);

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

the client code:

var mqtt = require('mqtt')
var client  = mqtt.connect('mqtt://192.168.124.1')
var tag = "mqtt-client-B";
client.on('connect', function () {
  client.subscribe('presence')
  client.publish('presence', 'Hello mqtt');
  setInterval(() => {
    client.publish('presence', 'Hello mqtt');
  }, 100);

})

client.on('message', function (topic, message) {
  // message is Buffer
  console.log(tag, message.toString())
  // client.end()
})