Skip to content

publish userProperties aren't returned in the PUBACK? #499

@dhyeyyyy

Description

@dhyeyyyy

Describe the issue

Looking to create a file-persistent queue for MQTT, was hoping to use userProperties to be able to link a publish with a pub ack. However- trying to experiment with this dummy program, the response contains an empty userProperties field. Is this the expected behaviour? How else could I go about connecting PUBACK's with their respective publishes?

const { iot, mqtt5, io } = require("aws-iot-device-sdk-v2");
io.enable_logging(io.LogLevel.DEBUG);

const certPath = "/home/dhyey/certificates";
const builder =
  iot.AwsIotMqtt5ClientConfigBuilder.newDirectMqttBuilderWithMtlsFromPath(
    host,
    certPath + "/certificate.pem.crt",
    certPath + "/private.pem.key"
  );
builder.withConnectProperties({
  clientId: "0x7effff03",
  keepAliveIntervalSeconds: 60,
});


builder.withAckTimeoutSeconds(5);

const config = builder.build();

const client = new mqtt5.Mqtt5Client(config);

client.on("error", (e) =>
  console.log("ERRORRR", e.toString(), client.getOperationalStatistics())
);

client.on("attemptingConnect", (e) => console.log("attemptconnect", e));

client.on("connectionSuccess", (e) => console.log("success", e));

client.on("connectionFailure", (e) =>
  console.log("failure", e, client.getOperationalStatistics())
);

client.on("disconnection", (e) =>
  console.log("disconnect", e, client.getOperationalStatistics())
);

client.on("stopped", (e) => console.log("stopped", e));
(async () => {
  try {
    while (true) {
      client.start();
      const res = await client.publish({
        qos: mqtt5.QoS.AtLeastOnce,
        topicName,
        payload: "helloo",
        userProperties: [{'name': 'id', 'value': 'hehe'}]
      });
      console.log("queue", client.getOperationalStatistics());
      console.log("result", JSON.stringify(res));
      await new Promise((resolve) => setTimeout(resolve, 5000));
    }
  } catch (err) {
    console.log("fatal", err);
  }
})();

output:

result {"type":4,"reasonCode":0,"userProperties":[]}

Links

https://aws.github.io/aws-iot-device-sdk-js-v2/node/interfaces/mqtt5.PublishPacket.html#userProperties

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationThis is a problem with documentation.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions