Environment:
- mqtt-v5 version: 0.31.4
- Rust version: 1.92.0
- OS: Ubuntu 24.04.1 (on WSL)
- MQTT Broker (if applicable):
Description:
Retained message does not save published message properties in the broker. I have tested this with response_topic and correlation_data properties. This is the mqtt-lib broker issue and it does not happens if I use another broker (e.g. nanomq).
To Reproduce:
Run mqtt-lib broker. Publish a retained message with response_topic and correlation_data to a topic. Then subscribe to that topic after message is published.
Run broker from command line with following command:
mqttv5 broker --allow-anonymous --storage-backend memory
and the run following code:
use mqtt5::{MqttClient, QoS, PublishOptions, PublishProperties};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client1 = MqttClient::new("my-device-001");
client1.connect("mqtt://localhost:1883").await?;
let client2 = MqttClient::new("my-device-002");
client2.connect("mqtt://localhost:1883").await?;
let options = PublishOptions {
qos: QoS::ExactlyOnce,
retain: true,
properties: PublishProperties {
response_topic: Some(String::from("sensors/response")),
..Default::default()
},
..Default::default()
};
// Publish a message
client1.publish_with_options("sensors/request", b"25C", options).await?;
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
// Subscribe with callback
client2.subscribe("sensors/request", |msg| {
println!("topic: {} payload: {}", msg.topic, String::from_utf8_lossy(&msg.payload));
println!("response_topic: {}", msg.properties.response_topic.map_or(String::from("response topic is None!"), |v| v));
}).await?;
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
Ok(())
}
Expected behavior:
The broker need to send response_topic and correlation_data as well for the retained message. In above code, I need to see response_topic: sensors/response in the output.
Actual behavior:
You will receive the message body, but response_topic and correlation_data are set to None. I see response_topic: response topic is None! in the output.
Additional context:
- Does this happen consistently or intermittently? Consistently
- Have you tested with different MQTT brokers? Yes. I have tested code with nanomq broker and I saw expected behavior there.
- Are you using any specific MQTT v5.0 features? Yes
For AI Agents:
- Verify reproduction steps are complete
- Check if this matches any known issues
- Validate environment information is complete
- Ensure error messages are included
Environment:
Description:
Retained message does not save published message properties in the broker. I have tested this with
response_topicandcorrelation_dataproperties. This is the mqtt-lib broker issue and it does not happens if I use another broker (e.g. nanomq).To Reproduce:
Run mqtt-lib broker. Publish a retained message with
response_topicandcorrelation_datato a topic. Then subscribe to that topic after message is published.Run broker from command line with following command:
and the run following code:
Expected behavior:
The broker need to send
response_topicandcorrelation_dataas well for the retained message. In above code, I need to seeresponse_topic: sensors/responsein the output.Actual behavior:
You will receive the message body, but
response_topicandcorrelation_dataare set to None. I seeresponse_topic: response topic is None!in the output.Additional context:
For AI Agents: