Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

connack sessionPresent flag is not send #231

Closed
mazhack opened this issue Mar 31, 2015 · 2 comments
Closed

connack sessionPresent flag is not send #231

mazhack opened this issue Mar 31, 2015 · 2 comments

Comments

@mazhack
Copy link

mazhack commented Mar 31, 2015

client's cleansession flag is false and session was stored, but sessionPresent is not send, paho client always set sessionPresent false, i review the client.js code and i dont find the sessionPresent flag...

  that.server.restoreClientSubscriptions(that, function() {
      client.connack({
        returnCode: 0
      });

      that.logger.info("client connected");
      that.server.emit("clientConnected", that);
      that.server.forwardOfflinePackets(that);
  });

connack never send sessionPresent flag... i can make a patch, but is necesary change the callback and persistence code, some like this:

  that.server.restoreClientSubscriptions(that, function(session_present) {  
       client.connack({
        returnCode: 0,
       // maybe session_present is null, custom old persistence engine
       // or not persistence defined
        sessionPresent: session_present ? true : false
      });

      that.logger.info("client connected");
      that.server.emit("clientConnected", that);
      that.server.forwardOfflinePackets(that);
  });

in persistence/abstract.js

 server.restoreClientSubscriptions = function restoreClientSubscriptions(client, done) {
    that.lookupSubscriptions(client, function(err, subscriptions) {
      if (err) {
        client.emit("error", err);
        return;
      }

      var subs = Object.keys(subscriptions);
      async.each(subs, function(topic, inCb) {
        client.logger.debug({ topic: topic, qos: subscriptions[topic].qos }, "restoring subscription");
        client.handleAuthorizeSubscribe(
          null, true, {
          topic: topic,
          qos: subscriptions[topic].qos
        }, inCb);
      }, function(){ done(subs.length === 0 ? false : true) });
    });
  };

what do you think about this?

@mcollina
Copy link
Collaborator

mcollina commented Apr 1, 2015

If you could send a PR it would be awesome! I knew about this problem, but I did not have enough bandwidth to get this sorted soonish.

@mazhack
Copy link
Author

mazhack commented Apr 2, 2015

I make the patch, but test it is too hard... I am still working on that

mazhack pushed a commit to mazhack/mosca that referenced this issue Apr 6, 2015
small fix in lib/persistence/abstract.js
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants