← Back to team overview

mosquitto-users team mailing list archive

Always received publish message even I restarted the server

 

Hi,All:
  I'm using mosquitto (mosquitto version 1.1.3 (build date 2013-02-22
19:49:18+0000)).
  and use node.js mqtt as client, and code shows below
var mqtt = require('mqtt');
console.log('test is started');
var receiveCount=0;
var subCount=0;
for(var i=0;i<1000;i++){
var client=mqtt.createClient(1883, 'myip');
client.connect({keepalive: 1000,client:'mqttClient'+i});
client.on('connack', function(packet) {
setInterval(function() {
  client.pingreq();
}, 1000);
});
console.log('connack i:'+i);
 client.subscribe({topic:'/hello/world/demo',qos:1});
client.on('suback', function(packet) {
//console.log('subscribe success');
console.dir(packet);
subCount++;
console.log('subCount success:'+subCount);
});
}
client.on('publish', function(packet) {
//console.log('received message');
receiveCount++;
console.log('received message'+receiveCount);
console.log('received publis topic:'+packet.topic);
console.log('received publis message:'+packet.payload);
console.log(new Date());
});

and I published a message with qos:1, I run the client couple times and
publish message couple time. After some while weird thing happened, anytime
when I run the client again, I always get the published message (topic is
'/hello/world/demo'). Then I restarted the mosiquitto server, but nothing
is changed, I always received the published message, even I did not publish
anything?
So here I need to know:
1. How to stop these stuff, I don't want to receive that spam message, but
restart does not work
2. Why does it happen? same client id causes this?
Thanks in advance!

Neo

Follow ups