{"action":"created","issue":{"url":"https://api.github.com/repos/mcollina/mosca/issues/262","labels_url":"https://api.github.com/repos/mcollina/mosca/issues/262/labels{/name}","comments_url":"https://api.github.com/repos/mcollina/mosca/issues/262/comments","events_url":"https://api.github.com/repos/mcollina/mosca/issues/262/events","html_url":"https://github.com/mcollina/mosca/issues/262","id":82407306,"number":262,"title":"Subscribing to $SYS receives nothing...","user":{"login":"behrad","id":2151889,"avatar_url":"https://avatars.githubusercontent.com/u/2151889?v=3","gravatar_id":"","url":"https://api.github.com/users/behrad","html_url":"https://github.com/behrad","followers_url":"https://api.github.com/users/behrad/followers","following_url":"https://api.github.com/users/behrad/following{/other_user}","gists_url":"https://api.github.com/users/behrad/gists{/gist_id}","starred_url":"https://api.github.com/users/behrad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/behrad/subscriptions","organizations_url":"https://api.github.com/users/behrad/orgs","repos_url":"https://api.github.com/users/behrad/repos","events_url":"https://api.github.com/users/behrad/events{/privacy}","received_events_url":"https://api.github.com/users/behrad/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-05-29T12:27:51Z","updated_at":"2015-05-29T13:25:39Z","closed_at":null,"body":"to build a simple dashboard I'm trying to subscribe for published $SYS stats and push them to statsd.\r\nHowever the code below doesn't seem to work for me :(\r\n```js\r\nvar mqtt    = require('mqtt');\r\n\r\nvar client  = mqtt.connect('mqtt://admin:admin@192.168.100.194:8883' );\r\n\r\n\r\nclient.on('connect', function () {\r\n  client.subscribe('$SYS/behrad-27601/clients/connected', function(err,sub){ // $SYS/# and $SYS/* also didn't work :(\r\n    console.log( \"subscription \",  sub );  //here sub.qos is 128 !!!????\r\n  });\r\n});\r\n\r\nclient.on('message', function (topic, message) {\r\n  // message is Buffer\r\n  console.log('%s: %s', topic, message.toString());\r\n  //client.end();\r\n});\r\n\r\nclient.on( 'error', function( err ) {\r\n  console.error( err );\r\n});\r\n```\r\n\r\nI would like to subscribe to $SYS/* to receive all stats."},"comment":{"url":"https://api.github.com/repos/mcollina/mosca/issues/comments/106801768","html_url":"https://github.com/mcollina/mosca/issues/262#issuecomment-106801768","issue_url":"https://api.github.com/repos/mcollina/mosca/issues/262","id":106801768,"user":{"login":"behrad","id":2151889,"avatar_url":"https://avatars.githubusercontent.com/u/2151889?v=3","gravatar_id":"","url":"https://api.github.com/users/behrad","html_url":"https://github.com/behrad","followers_url":"https://api.github.com/users/behrad/followers","following_url":"https://api.github.com/users/behrad/following{/other_user}","gists_url":"https://api.github.com/users/behrad/gists{/gist_id}","starred_url":"https://api.github.com/users/behrad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/behrad/subscriptions","organizations_url":"https://api.github.com/users/behrad/orgs","repos_url":"https://api.github.com/users/behrad/repos","events_url":"https://api.github.com/users/behrad/events{/privacy}","received_events_url":"https://api.github.com/users/behrad/received_events","type":"User","site_admin":false},"created_at":"2015-05-29T13:25:38Z","updated_at":"2015-05-29T13:25:38Z","body":"Does relates to auth, disabling it makes things work!\r\n\r\nmy credentials file\r\n```json\r\n{\r\n  \"test\": {\r\n    \"salt\": \"UuIcCn21AlkG287RM/cyO1SOxn0X92bBFHUBBIZGi7B9vYCjx/Bj2d6XTCLpRnatfddNOpH3WyIWY2KInKLyYA==\",\r\n    \"hash\": \"f6Qzt34am/xpEqB0uUAMufJGOPtJLsDwhztLTx+qvpb1Bq39jt2eqwVR908EIGWh5pFaORnZXmblnIwazjSjWNvJlzILeZde6Hk0Zcb+264sNaPDQ9n4yGHwZ4pn2dLU8lVjF9ASnaDPyqYQLOKDAMBaR0r8BDPz+IeZLJ5KqRA=\",\r\n    \"authorizePublish\": \"test*\",\r\n    \"authorizeSubscribe\": \"test*\"\r\n  },\r\n  \"admin\": {\r\n    \"salt\": \"v9yW8RGiPvIqn4gixLjxTFsCoTzfnSHDG0Bv6I93/ogfgffo95WwJzcIorf2wrOGixHy0lR7K4D264iE3hS/Yg==\",\r\n    \"hash\": \"EceNP7/CsQRJCD5IiufBa93ig3FWbvlqeCzEJDvyO7nxuAliXCnsJguf1uX4bqotI7SQmjTibxL/+kAyYl/7O/6bjGVHtDOYSHLOQ7IIe30DklC64vYRGvapgzOquoG/sdDDR2V4ePqT2t8z4/FE0oD7py3TxUM0yXQa7izf0AE=\",\r\n    \"authorizePublish\": \"*\",\r\n    \"authorizeSubscribe\": \"*\"\r\n  }\r\n}\r\n```\r\n\r\nand my bootstrapper code:\r\n```js\r\nvar fs = require(\"fs\");\r\n  var Authorizer = require(\"mosca/lib/authorizer\");\r\n  function loadAuthorizer(program, cb) {\r\n    //program.credentials = __dirname + \"/../mqtt_credentials.json\";\r\n    if (program.mqtt_credentials) {\r\n      fs.readFile(program.mqtt_credentials, function(err, data) {\r\n        if (err) {\r\n          cb(err);\r\n          return;\r\n        }\r\n        var authorizer = new Authorizer();\r\n        try {\r\n          authorizer.users = JSON.parse(data);\r\n          cb(null, authorizer);\r\n        } catch(err) {\r\n          cb(err);\r\n        }\r\n      });\r\n    } else {\r\n      cb(null, null);\r\n    }\r\n  }\r\n\r\n// used in broker.on('ready')\r\nfunction setup() {\r\n    loadAuthorizer(moscaSettings, function(err, authorizer) {\r\n      if (err) {\r\n        console.error( 'Error authorizing request ', err );\r\n        debug( 'Error authorizing request ', err );\r\n      }\r\n      if (authorizer) {\r\n        server.authenticate = authorizer.authenticate;\r\n        server.authorizeSubscribe = authorizer.authorizeSubscribe;\r\n        server.authorizePublish = authorizer.authorizePublish;\r\n      }\r\n    });\r\n    debug('Broker is up and running');\r\n  }\r\n```"}}