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

AUTH packets with no body should be allowed #2039

Closed
gordonwang0 opened this issue Jul 9, 2024 · 0 comments · Fixed by #2070
Closed

AUTH packets with no body should be allowed #2039

gordonwang0 opened this issue Jul 9, 2024 · 0 comments · Fixed by #2070
Labels
bug Something isn't working

Comments

@gordonwang0
Copy link

Verification

Per the MQTT spec, AUTH packets with Reason Success are allowed to omit the body:

The Reason Code and Property Length can be omitted if the Reason Code is 0x00 (Success) and there are no Properties. In this case the AUTH has a Remaining Length of 0.

Therefore, the AUTH packet [0xf0, 0x00] is valid, as this has:

  • 0xf0 : AUTH header
  • 0x00 : Remaining length = 0

Describe the bug

MQTTnet doesn't accept these packets. It throws an exception when trying to parse these packets:

MQTTnet.Exceptions.MqttProtocolViolationException: Data from the body is required but not present.
   at MQTTnet.Formatter.V5.MqttV5PacketDecoder.ThrowIfBodyIsEmpty(ArraySegment`1 body)
   at MQTTnet.Formatter.V5.MqttV5PacketDecoder.DecodeAuthPacket(ArraySegment`1 body)
   at MQTTnet.Formatter.V5.MqttV5PacketDecoder.Decode(ReceivedMqttPacket receivedMqttPacket)
   at MQTTnet.Formatter.V5.MqttV5PacketFormatter.Decode(ReceivedMqttPacket receivedMqttPacket)
   at MQTTnet.Formatter.MqttPacketFormatterAdapter.Decode(ReceivedMqttPacket receivedMqttPacket)
   at MQTTnet.Adapter.MqttChannelAdapter.ReceivePacketAsync(CancellationToken cancellationToken)
   at MQTTnet.Client.MqttClient.Receive(CancellationToken cancellationToken)
   at MQTTnet.Client.MqttClient.ReceivePacketsLoop(CancellationToken cancellationToken)

Which component is your bug related to?

  • Client

Expected behavior

The AUTH packet [0xf0, 0x02, 0x00, 0x00] works fine. This has:

  • 0xf0 - AUTH header
  • 0x02 - Remaining length = 2
  • 0x00 - Reason Success
  • 0x00 - Property length = 0

Per the MQTT spec, the AUTH packets [0xf0, 0x00] and [0xf0, 0x02, 0x00, 0x00] should be treated as equivalent, so both should work with MQTTnet.

@gordonwang0 gordonwang0 added the bug Something isn't working label Jul 9, 2024
@chkr1011 chkr1011 linked a pull request Aug 25, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant