Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT /get flow #11

Open
andreareginato opened this issue Dec 24, 2014 · 0 comments
Open

MQTT /get flow #11

andreareginato opened this issue Dec 24, 2014 · 0 comments
Labels

Comments

@andreareginato
Copy link
Contributor

After the Redis configuration the /get definition is not working. Most probably the /get channel with Mosca (or Ascoltatori) is defined as a Buffer(hex).

We need to understand how to fix this problem to make things correctly work as right now we "hack" this problem by defining a MQTT

// NORMAL FLOW (using Ascoltatori)
publish(req, '/get/')
var publish = function(req, mode) {
  payload = { message: req.body };
  payload.message = new Buffer(payload.message, 'hex');
  var topic = 'devices/' + req.params.id + mode;
  debug('[API REQ] Publishing topic', topic, req.body, payload.toString());

  ascoltatore.publish(topic, req.body, function() {
    console.log('[API REQ] Message published to the topic', topic, req.body);
  });
}
// HACK
var client = mqtt.createClient(port, host, { username: req.params.id, password: req.get('X-Physical-Secret') });
client.on('connect', function() {
   client.publish('devices/' + req.params.id + '/get', JSON.stringify(req.body));
   client.end();
})

One further note (obvious) is that the MQTT client (pass through Mosca) works just fine. If I pass through Ascoltatori it doesn't set properly the payload. We need to understand how Mosca uses ascoltatori to store the Redis messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant