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

generate function cannot handle zero-length client identifiers #68

Closed
janniswarnat opened this issue Sep 24, 2019 · 0 comments · Fixed by #104
Closed

generate function cannot handle zero-length client identifiers #68

janniswarnat opened this issue Sep 24, 2019 · 0 comments · Fixed by #104

Comments

@janniswarnat
Copy link

Hi all,

thank you for providing this very helpful package :-).

The MQTT standard version 5 allows clients to connect using a zero-length client identifier. Yet the generate function seems not to be able to handle this:

const mqtt = require('mqtt-packet');
const opts = {protocolVersion: 5};
const parser = mqtt.parser(opts);

parser.on('packet', (packet) => {
    console.log("packet event emitted on noopParser", packet);
});

parser.on('error', (error) => {
    console.log("error event emitted on noopParser", error.message);
});

let packet = {
    cmd: "connect",
    protocolId: "MQTT",
    protocolVersion: 5,
    clean: true,
    keepalive: 60,
    properties:
        {
            receiveMaximum: 20
        },
    clientId:""
};

let generatedBuffer = mqtt.generate(packet, opts);
console.log('generatedBuffer',generatedBuffer);
parser.parse(generatedBuffer);

This will give error message "Packet too short" when parsing the generated buffer.

Thanks in advance for your feedback and best regards

Jannis

janniswarnat pushed a commit to janniswarnat/mqtt-packet that referenced this issue Nov 19, 2019
Allow zero-length client identifiers also for MQTT version 5
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

Successfully merging a pull request may close this issue.

1 participant