Report unauthorized subscription
Describe the feature request
The public MQTT broker on broker.emqx.io doesn't allow subscribing to #. The client MQTTX tells me after I try that it has failed because I'm not authorized to do that. MQTTnet doesn't tell me. I've looked around for any members of the result object or the client itself but couldn't find anything and no exception is thrown. The subscription was apparently successful but I receive no data after that.
Which project is your feature request related to?
MQTTnet's MqttClient class, I guess, or anywhere, I don't know what you mean.
Describe the solution you'd like
Best would be an exception or some information in the MqttClientSubscribeResult class.
Describe alternatives you've considered
N/A
Additional context
Please provide a full code sample.
Generally the broker does not deny subscriptions by default (event when subscribing to '#').
If you want to deny such a subscription please use the event InterceptingSubscriptionAsync. There you can set the response code to NotAuthorized etc. and thus deny the subscription.
Sorry, the requested information can no longer be found. But I guess I was using the MQTTnet client, not server. And that client just didn't tell me what the MQTTX application could. So it appeared to me that MQTTnet client silently ignores error responses from a broker.
The method SubscribeAsyncreturns a MqttClientSubscribeResult which has Items. One per topic filter which as sent before. Such an item has a ResultCode which should contain the same error code. But it requires that you set the protocol version to 5.0.0. Otherwise the error code are very limited. Is this what you are looking for?