Skip to content

Commit

Permalink
[FIXED] MQTT PUBREL header incompatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
levb committed Oct 2, 2023
1 parent 4165f86 commit e5d3f4a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions server/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -3915,6 +3915,14 @@ func (c *client) mqttEnqueuePubResponse(packetType byte, pi uint16, trace bool)
proto := [4]byte{packetType, 0x2, 0, 0}
proto[2] = byte(pi >> 8)
proto[3] = byte(pi)

// Bits 3,2,1 and 0 of the fixed header in the PUBREL Control Packet are
// reserved and MUST be set to 0,0,1 and 0 respectively. The Server MUST treat
// any other value as malformed and close the Network Connection [MQTT-3.6.1-1].
if packetType == mqttPacketPubRel {
proto[0] |= 0x2
}

c.mu.Lock()
c.enqueueProto(proto[:4])
c.mu.Unlock()
Expand Down

0 comments on commit e5d3f4a

Please sign in to comment.