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

Options in constructor not being saved #25

Closed
miqmago opened this issue Mar 13, 2019 · 1 comment
Closed

Options in constructor not being saved #25

miqmago opened this issue Mar 13, 2019 · 1 comment

Comments

@miqmago
Copy link

miqmago commented Mar 13, 2019

After digging a little bit more on the library, I've closed #24 and opening this one as found what it seems a bug, or at least a miss-documentation.

const client = mqttCon(stream, {
    protocolVersion: 5,
    protocolId: 'MQTT',
});
console.log(client.options);

Outputs undefined.

const client = mqttCon(stream);
client.setOptions({
    protocolVersion: 5,
    protocolId: 'MQTT',
});
console.log(client.options);

Outputs { protocolVersion: 5, protocolId: 'MQTT' }.

This has a big implication, as it causes errors on subscriptions (cannot subscribe as topic cannot be decoded) and also on publish events receives payloads with extra 00 byte at the begining, corresponding to undecoded properties:

Server is sending the content with the space for properties but client is not consuming them, so there are some bytes not being consumed and being left in payload.

Also on the contrary, the client sends a packet with properties bytes codified, and then server is not consuming the properties so they remain in payload, making payload to be displaced so cannot be correctly decoded:

from parser.js:

  // Properties mqtt 5
  if (this.settings.protocolVersion === 5) {
    var properties = this._parseProperties()
    if (Object.getOwnPropertyNames(properties).length) {
      packet.properties = properties
    }
  }
@miqmago
Copy link
Author

miqmago commented Mar 13, 2019

Opening it in correct library: mqttjs/mqtt-packet#50

@miqmago miqmago closed this as completed Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant