Description
Is there a bug in msg->get_properties() ?
Am I doing anything wrong?
I looked at the properties samples and I'm using it in the same way.
I tried different brokers thinking something in the broker could be wrong and I get the same results. I also installed the latest mosquitto broker in my laptop and used localhost as broker and it didn't work.
properties in paho cpp are not working when I use msg->get_properties() in message_arrived, but properties in message_arrive work in python.
I run both subscribers the python version and the cpp version at the same time subscribing to the same topic (the publisher is in c++)
** Subscriber python version output:**
Received message: Hello, MQTT! on topic ggg/test/topic
Message Properties:
[UserProperty : [('key1', 'value1'), ('key2', 'value2')]]
** Subscriber c++ output:**
Message arrived: ggg/test/topic -> Hello, MQTT!
No hay user property, porqueeee?? (This means "There is no user property, whyyyy?" )
Is props empty? '1'
props size: '0'
Below is my c++ subscriber message_arrived code
` void message_arrived(mqtt::const_message_ptr msg) override {
std::cout << "Message arrived: " << msg->get_topic() << " -> " << msg->to_string() << std::endl;
const mqtt::properties& props = msg->get_properties();
if (props.contains(mqtt::property::USER_PROPERTY)){
std::cout << "Lo logrè, mamà\n" << std::endl;
}
else {
std::cout << "No hay user property, porqueeee??" << std::endl;
}
std::cout << "Is props empty? '" << props.empty() << "'" << std::endl;
std::cout << "props size: '" << props.size() << "'" << std::endl;
}`
Please kindly help!