You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Additional context
Issue appears to be handling of FixedHeader.Flags in func (c *ControlPacket) WriteTo(w io.Writer) (int64, error). The Unpacker checks Flags and sets the QOS but WriteTo does not do the reverse.
Note: I am working on a fix.
The text was updated successfully, but these errors were encountered:
Calling WriteTo on the ControlPacket type (srcCP in the test) fails
Calling WriteTo on the Publish type (srcP in the test) is successful
This means (I think) that this is not currently causing any issues because a PUBLISH will always be sent via WriteTo on the Publish type. However, if ControlPacket is going to have a WriteTo then is should work for all packet types.
The way this currently works for other packets relies on a degree of duplication. For example in pubrel.go we write with &ControlPacket{FixedHeader: FixedHeader{Type: PUBREL, Flags: 2}} and Flags is also set to the required value (2) in packets.go with case PUBREL: cp.Flags = 2; cp.Content = &Pubrel{Properties: &Properties{}}. This works but the duplication is not ideal.
Looking at section 2.1.3 ("Flags") in the spec if looks like "PUBLISH" is the only packet with variable flags so I will implement a quick fix for now but it would be worth considering refactoring this in the future.
Anyway the PR fixes this by duplicating some code from publish.go into packets.go. I have also added a test which should ensure that both versions work (could probably be enhanced to check other flags).
Describe the bug
When unpacking QOS1+ PUBLISH packets the QOS level is not being set in the header.
To reproduce
Debug output
Expected behaviour
The test should pass
Software used:
@master
Additional context
Issue appears to be handling of
FixedHeader.Flags
infunc (c *ControlPacket) WriteTo(w io.Writer) (int64, error)
. The Unpacker checks Flags and sets the QOS but WriteTo does not do the reverse.Note: I am working on a fix.
The text was updated successfully, but these errors were encountered: