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

Unable to get MqttClientPublishResult from PublishAsync without error thrown? #2140

Open
invisicow opened this issue Jan 17, 2025 · 0 comments

Comments

@invisicow
Copy link

invisicow commented Jan 17, 2025

Discussed in #2139

Originally posted by invisicow January 17, 2025
Hi,

I am testing my error handling when calling PublishAsync() to a bad topic, such as "####", but I am getting unexpected behavior.

Expected:
I expected PublishAsync() to return an MqttClientPublishResult instance with ReasonCode having value MqttClientPublishReasonCode.TopicNameInvalid.

Actual:
Instead, I am getting exception

MQTTnet.Exceptions.MqttProtocolViolationException: 'The character '#' is not allowed in topics.'

This is rather unfortunate, because using specific MqttClientPublishReasonCode values from the MqttClientPublishResult would help my error handling. Is there a way to receive this result object back without the method throwing an error?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant