Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ManagedMqttClient.SubscribeAsync does not handle or inform about subscription errors #1955

Open
xnoreq opened this issue Mar 20, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@xnoreq
Copy link

xnoreq commented Mar 20, 2024

Describe the bug

ManagedMqttClient simply calls await InternalClient.SubscribeAsync(subscribeOptionsBuilder.Build()).ConfigureAwait(false); without handling the return value.

The return value of type MqttClientSubscribeResult contains a collection of MqttClientSubscribeResultItem which have a ResultCode.
This result code can indicate subscription errors, such as 0x8F (TopicFilterInvalid).

I'd rate this as a SEVERE bug, because the caller does not know whether subscriptions succeeded or failed.

Which component is your bug related to?

  • ManagedClient

To Reproduce

Steps to reproduce the behavior:

  1. MQTTnet version 4.3.3.952
  2. Optional: set up a MqttNetEventLogger to log verbose messages (to print the SubAck packet with subscription result code)
  3. Call await client.SubscribeAsync(invalidTopic)

Expected behavior

Either await client.SubscribeAsync(invalidTopic) should fail with an exception, or due to the background processing and event-based architecture of ManagedMqttClient fire a new event such as "SubscriptionsFailedAsync" with args that contain the subscription result code.

@xnoreq xnoreq added the bug Something isn't working label Mar 20, 2024
@xnoreq
Copy link
Author

xnoreq commented Mar 20, 2024

It looks like this is already implemented on master with the event SubscriptionsChangedAsync (commit aabf180).
When is this going to be release as a nuget package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant