MQTTnet
MQTTnet copied to clipboard
WithSubscriptionIdentifier(uint subId) lies...
Describe the bug
Create a 32-bit CRC that you want to use as a subscription identifier that ends up equaling 1726790899.
Call WithSubscriptionIdentifier(1726790899) to set the identifier on a subscription. Apply the subscription to the client.
Call client.ConnectAsync .
Receive an exception with the message The specified value (1726790899) is too large for a variable byte integer.
Which component is your bug related to?
- Client
To Reproduce
See description.
Expected behavior
Since the method accepts a uint as a parameter, I expect it to be accepted and not subjected to an arbitrary limit of 268435455. That's 2^28 - 1 which is very off of the max uint value of 2^32 - 1.
Okay... I now understand that the max value is part of the MQTT v5 specification, so the limit is not arbitrary on the part of MQTTnet.
Is it possible to enforce this value at the time of the call to WithSubscriptionIdentifier instead of waiting for the connect call? And also put something in the API docs so that it is obvious what the constraints are without having to have read the specs?
There are already some validations for the options when connecting etc. I will add more validations for the large integers...