Server: MongoDB(persistence) + Mosca running on linux Server
(Sample example:mtqq_engine.js, build one broker with mosca)
Simulate_client: MQTT
(Sample example:client_mosca_bug.js, set clean to false to receive the offline message, this client subscribes topic (/device001) at the beginning and unsubscribes the same topic after 20s.)
After client unsubscribed the topic(/device001), mongoDB should DELETE this topic of this client from Collection Subscriptions, AND it does NOT, the consequence is whenever restart this client without subscribing any topic, it will still receive the message from the Unsubscribed topic(/device001) which should NOT happen at all.
I checked #391, {+ that.server.persistClient(that);} is in my /lib/client.js, seems like the problem is not cured by it.
Currently I have to tell the mosca sever to access MongoDB to delete the corresponding topic whenever it received the UNsubscribe message.
@mcollina same problem as issue #382
Server: MongoDB(persistence) + Mosca running on linux Server (Sample example:mtqq_engine.js, build one broker with mosca)
Simulate_client: MQTT (Sample example:client_mosca_bug.js, set clean to false to receive the offline message, this client subscribes topic (/device001) at the beginning and unsubscribes the same topic after 20s.)
After client unsubscribed the topic(/device001), mongoDB should DELETE this topic of this client from Collection Subscriptions, AND it does NOT, the consequence is whenever restart this client without subscribing any topic, it will still receive the message from the Unsubscribed topic(/device001) which should NOT happen at all.
I checked #391, {+ that.server.persistClient(that);} is in my /lib/client.js, seems like the problem is not cured by it.
Currently I have to tell the mosca sever to access MongoDB to delete the corresponding topic whenever it received the UNsubscribe message.
Cheers, Xintao
server screenshot:![server](https://cloud.githubusercontent.com/assets/7420058/17772531/92078626-6549-11e6-996c-b8c7d7bef5f4.png)
client_generate_bug screenshot:![client](https://cloud.githubusercontent.com/assets/7420058/17772547/a729a034-6549-11e6-81fa-efaadef0b417.png)
MongoDB screenshot(the topic should be deleted):![mongodb](https://cloud.githubusercontent.com/assets/7420058/17772627/19b64bfc-654a-11e6-80e4-32ddf943635f.png)
server code: ` var mosca = require('mosca');
//use mongoDB as offline persistence backend var settings = { port: 5113, backend:{ type: 'mongo', url: 'mongodb://xxxxxxxxxx0.0.0.0:27017/mqtt', pubsubCollection: 'ascoltatori', mongo: {} }, persistence:{ factory: mosca.persistence.Mongo, url: "mongodb://xxxxxxxxxx0.0.0.0:27017/mqtt", } };
//create mqtt server and provice interface to other components var mqtt_engine = new mosca.Server(settings);
function setup(){ console.log("MQTT_BROKER IS RUNNING @PORT 5113"); }
mqtt_engine.on('ready', setup);
mqtt_engine.on('published', function(packet, client) { console.log('published', packet.payload.toString()); });
mqtt_engine.on('clientConnected', function(client) { console.log('client connected', client.id); });
mqtt_engine.on('clientDisconnected', function(client) { console.log('client disconnected', client.id); });
mqtt_engine.on('subscribed', function(topic,client) { console.log(client.id,' subscribed ',topic); });
mqtt_engine.on('unsubscribed', function(topic,client) { console.log(client.id,' unsubscribed ',topic); }); `
client_generate_bug code: ` var mqtt = require('mqtt');
var settings = { keepalive: 10, protocolId: 'MQIsdp', protocolVersion: 3, clientId: 'android', clean: false }
var client = mqtt.connect('mqtt://xxxxxxxxxxxx:5113',settings);
client.subscribe('/device001',{qos:1},function(){ console.log('#android subscribed #topic /device001 #ok.'); });
var num = 0; setInterval(function (){ client.unsubscribe('/device001',function(){ console.log('#android UNsubscribed #topic /device001 #ok.'); }); }, 20000); `