eclipse-paho / paho.mqtt.golang

Other
2.77k stars 534 forks source link

Won't return an error in the token when publish a message to a forbidden topic(forbidden by ACL) ? #584

Closed Explorer0 closed 2 years ago

MattBrittan commented 2 years ago

When posting an issue please take the time to include the details requested in the readme.

I believe that you are suggesting that sending a publish that a Broker ignores due to an ACL should result in an error. If that is the case then you need to take a look at the MQTT Spec:

If a Server implementation does not authorize a PUBLISH to be performed by a Client; it has no way of informing that Client. It MUST either make a positive acknowledgement, according to the normal QoS rules, or close the Network Connection [MQTT-3.3.5-2].

So the broker has no way of telling the client that a PUBLISH is unauthorised meaning the client has no way of telling your code. The broker could choose to drop the connection but its likely that the client will just reconnect and try to resend the message (leading to an infinite loop) so I believe most brokers just acknowledge the message and then throw it away.

MattBrittan commented 2 years ago

Closing due to inactivity and insufficient information.