4. PUBLISH accepts QoS = 3 and treats it as QoS = 0
Though not explicitly stated, the expected behaviour is closing the
connection.
If the Client or Server encounters a transient error while processing an
inbound Control Packet it MUST close the Network Connection on which it
received that packet [MQTT-4.8.0-1].
I agree that it accepts QoS = 3, but disagree that it treats it as QoS = 0.
Fixed.
Correct, it just accepts the QoS 3 message, but does not publish it out to subscribers:
1395248324: mosquitto version 1.3 (build date 2014-03-17 13:32:15+0000) starting
… PUBLISH QoS 0
1395248345: New connection from 192.168.178.41 on port 1883.
1395248345: New client connected from 192.168.178.41 as MQTTClient-416941146.388949 (c1, k60).
1395248345: Sending CONNACK to MQTTClient-416941146.388949 (0)
1395248346: Received SUBSCRIBE from MQTTClient-416941146.388949
1395248346: MQTTClient/# (QoS 2)
1395248346: MQTTClient-416941146.388949 2 MQTTClient/#
1395248346: Sending SUBACK to MQTTClient-416941146.388949
1395248347: Received PUBLISH from MQTTClient-416941146.388949 (d0, q0, r0, m0, 'MQTTClient/-[MQTTClientPublishTests testPublish_r0_q0]', ... (43 bytes))
1395248347: Sending PUBLISH to MQTTClient-416941146.388949 (d0, q0, r0, m0, 'MQTTClient/-[MQTTClientPublishTests testPublish_r0_q0]', ... (43 bytes))
1395248348: Received DISCONNECT from MQTTClient-416941146.388949
… PUBLISH QoS 3
1395248354: New connection from 192.168.178.41 on port 1883.
1395248354: New client connected from 192.168.178.41 as MQTTClient-416941155.422045 (c1, k60).
1395248354: Sending CONNACK to MQTTClient-416941155.422045 (0)
1395248355: Received SUBSCRIBE from MQTTClient-416941155.422045
1395248355: MQTTClient/# (QoS 2)
1395248355: MQTTClient-416941155.422045 2 MQTTClient/#
1395248355: Sending SUBACK to MQTTClient-416941155.422045
1395248356: Received PUBLISH from MQTTClient-416941155.422045 (d0, q3, r0, m3, 'MQTTClient/-[MQTTClientPublishTests testPublish_r0_q3]', ... (43 bytes))
1395248366: Received DISCONNECT from MQTTClient-416941155.422045
5. CONNECT accepts will QoS = 3 and treats it as QoS = 0
If the Will Flag is set to 1, the value of Will QoS can be 0 (0x00), 1
(0x01), or 2 (0x02). It MUST NOT be 3 (0x03). [MQTT-3.1.2-12].
I disagree, this check is already in place. I wonder if your QoS = 3 tests
aren't quite right.
You are right, the client library had a bug, shifting the will QoS 1 bit too far to the left (making a 2 out of the 3);
Mosquitto reacts correctly by closing the connection and does not CONNACK the CONNECT.
Mosquitto is a great tool!
Best,
Christoph