paho.mqtt.python icon indicating copy to clipboard operation
paho.mqtt.python copied to clipboard

publish return code always 0, even if failure with access denied in restricted topic

Open call-me-matt opened this issue 2 years ago • 7 comments

I would like to detect if a publish message has been sent or rejected by the broker when restricting access with ACL.

expected: return code 135 if access denied

as-is: return code is always 0 - even if the message is not published by the broker because of ACL denial.

I am using mqtt v5 and qos1,

properties=Properties(PacketTypes.PUBLISH)
properties.MessageExpiryInterval=5 # retain messages for x seconds
ret = self.__mqtt_client.publish(restricted_data, payload, retain=1, qos=1, properties=properties)
ret.wait_for_publish()
print(ret.is_published()) # always True
print (f" RET={ret.rc}") # always 0

Tested with nodejs mqtt library, and saw an authorization error - so the broker works as expected.

call-me-matt avatar Apr 06 '23 08:04 call-me-matt

oh, there is already a pull request! https://github.com/eclipse/paho.mqtt.python/pull/656 please merge, this is very necessary

call-me-matt avatar Apr 24 '23 08:04 call-me-matt

Hi. I am also experiencing a similar situation. The return code of the publish function is always 0, even if the topic does not exist. I reinforce that this correction is very necessary.

dgbarmac avatar May 17 '23 19:05 dgbarmac

Hi, would just like to reiterate that this is feature is critical for QOS 2 applications. Please fix soon!

jayzym avatar Jul 25 '23 15:07 jayzym

Same here! hopefully, it will be resolved soon. I'll be watching 👀

AlejandroPOcz avatar Jul 25 '23 16:07 AlejandroPOcz

This is a critical bug that is forcing us to verify manually what should be an automated process.

kevin-hardy avatar Jul 26 '23 17:07 kevin-hardy

We have the same issue, please merge / release a fix soon!

polarhub avatar Jul 26 '23 18:07 polarhub

Hi we are getting the issue issue. It's important to us. Please merge it soon!

jzjz12 avatar Aug 02 '23 20:08 jzjz12