{"action":"created","issue":{"url":"https://api.github.com/repos/mqttjs/MQTT.js/issues/352","labels_url":"https://api.github.com/repos/mqttjs/MQTT.js/issues/352/labels{/name}","comments_url":"https://api.github.com/repos/mqttjs/MQTT.js/issues/352/comments","events_url":"https://api.github.com/repos/mqttjs/MQTT.js/issues/352/events","html_url":"https://github.com/mqttjs/MQTT.js/issues/352","id":118416285,"number":352,"title":"Client is unsubscribed when disconnected ","user":{"login":"vallettea","id":371303,"avatar_url":"https://avatars.githubusercontent.com/u/371303?v=3","gravatar_id":"","url":"https://api.github.com/users/vallettea","html_url":"https://github.com/vallettea","followers_url":"https://api.github.com/users/vallettea/followers","following_url":"https://api.github.com/users/vallettea/following{/other_user}","gists_url":"https://api.github.com/users/vallettea/gists{/gist_id}","starred_url":"https://api.github.com/users/vallettea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vallettea/subscriptions","organizations_url":"https://api.github.com/users/vallettea/orgs","repos_url":"https://api.github.com/users/vallettea/repos","events_url":"https://api.github.com/users/vallettea/events{/privacy}","received_events_url":"https://api.github.com/users/vallettea/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-11-23T16:18:52Z","updated_at":"2015-11-25T14:21:19Z","closed_at":null,"body":"Here is a code to reproduce what i mean:\r\n\r\n```\r\n\"use strict\";\r\n\r\nvar mqtt = require('mqtt');\r\n\r\nvar PRIVATE = require('./PRIVATE.json');\r\n\r\nvar simId = \"0000\"\r\n\r\nvar client = mqtt.connect('mqtt://' + PRIVATE.host + ':' + PRIVATE.port,\r\n    {\r\n        username: simId,\r\n        password: PRIVATE.mqttToken,\r\n        clientId: simId,\r\n        keepalive: 1,\r\n        clean: false,\r\n        // Do not set to a value > 29 until this bug is fixed : https://github.com/mqttjs/MQTT.js/issues/346\r\n        reconnectPeriod: 1000 * 1\r\n    }\r\n);\r\n\r\n\r\nclient.on('connect', function(){\r\n    console.log('connected to the server. ID :', simId);\r\n});\r\n\r\nclient.on('message', function(topic, message) {\r\n    // message is a Buffer\r\n    console.log(\"data received : \" + message.toString());\r\n});\r\n\r\nclient.on(\"error\", function(error) {\r\n    console.log(\"ERROR: \", error);\r\n});\r\n\r\nclient.on('offline', function() {\r\n    console.log(\"offline\");\r\n});\r\n\r\nclient.on('reconnect', function() {\r\n    console.log(\"reconnect\");\r\n});\r\n    \r\n\r\nsetTimeout(function(){\r\n   client.subscribe('test'); \r\n}, 3000)\r\n\r\n//start sending\r\nvar i = 0;\r\nsetInterval(\r\n    function(){\r\n        var message = i.toString();\r\n        console.log(\"sending \", message)\r\n        client.publish(\"test\", message, {qos: 1}, function(){\r\n            console.log(\"sent \", message)\r\n        });\r\n        i += 1;\r\n    },\r\n3000)\r\n```\r\n\r\nIt outputs:\r\n\r\n```\r\nsending  0\r\nsent  0\r\ndata received : 0\r\nsending  1\r\nsent  1\r\ndata received : 1\r\nsending  2\r\noffline\r\nreconnect\r\nsending  3\r\nsending  4\r\nsending  5\r\nsending  6\r\nsending  7\r\nsending  8\r\nsending  9\r\nsending  10\r\nsending  11\r\nsending  12\r\noffline\r\nreconnect\r\nconnected to the server. ID : 0000\r\nsent  3\r\nsent  4\r\nsent  5\r\nsent  6\r\nsent  7\r\nsent  8\r\nsent  9\r\nsent  10\r\nsent  11\r\nsent  12\r\nsending  13\r\nsent  13\r\nsending  14\r\nsent  14\r\nsending  15\r\nsent  15\r\n```\r\n\r\nthis outputs suggests that once disconnected, the client reconnects and sends the message which is received by another client listening to the subject (i've checked). however the client seems to not be subscribed to the topic `test` anymore.\r\n\r\nIs this normal, or I am missing something ?\r\nthx"},"comment":{"url":"https://api.github.com/repos/mqttjs/MQTT.js/issues/comments/159620323","html_url":"https://github.com/mqttjs/MQTT.js/issues/352#issuecomment-159620323","issue_url":"https://api.github.com/repos/mqttjs/MQTT.js/issues/352","id":159620323,"user":{"login":"vallettea","id":371303,"avatar_url":"https://avatars.githubusercontent.com/u/371303?v=3","gravatar_id":"","url":"https://api.github.com/users/vallettea","html_url":"https://github.com/vallettea","followers_url":"https://api.github.com/users/vallettea/followers","following_url":"https://api.github.com/users/vallettea/following{/other_user}","gists_url":"https://api.github.com/users/vallettea/gists{/gist_id}","starred_url":"https://api.github.com/users/vallettea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vallettea/subscriptions","organizations_url":"https://api.github.com/users/vallettea/orgs","repos_url":"https://api.github.com/users/vallettea/repos","events_url":"https://api.github.com/users/vallettea/events{/privacy}","received_events_url":"https://api.github.com/users/vallettea/received_events","type":"User","site_admin":false},"created_at":"2015-11-25T14:21:19Z","updated_at":"2015-11-25T14:21:19Z","body":"I've configured the offline storage like so for mosca:\r\n\r\n```\r\nvar pubsubsettings = {\r\n  type: 'redis',\r\n  redis: require('redis'),\r\n  db: 12,\r\n  host: process.env.REDIS_PORT_6379_TCP_ADDR,\r\n  port: process.env.REDIS_PORT_6379_TCP_PORT,\r\n  return_buffers: true\r\n};\r\n\r\nvar moscaSettings = {\r\n  port: 1883,\r\n  backend: pubsubsettings,\r\n  persistence: {\r\n    factory: mosca.persistence.Redis,\r\n    host: process.env.REDIS_PORT_6379_TCP_ADDR,\r\n    port: process.env.REDIS_PORT_6379_TCP_PORT,\r\n  }\r\n};\r\n```\r\n\r\nbut i still get a `sessionPresent: false` after reconnexion"}}