-
Notifications
You must be signed in to change notification settings - Fork 102
Closed
Labels
documentationThis is a problem with documentation.This is a problem with documentation.needs-triageThis issue or PR still needs to be triaged.This issue or PR still needs to be triaged.
Description
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
Metadata
Metadata
Assignees
Labels
documentationThis is a problem with documentation.This is a problem with documentation.needs-triageThis issue or PR still needs to be triaged.This issue or PR still needs to be triaged.