moscajs / mosca

MQTT broker as a module
mosca.io
3.2k stars 513 forks source link

Incorrect QoS - Mosca upgrades QoS set by publisher #769

Open BorisPetelj opened 5 years ago

BorisPetelj commented 5 years ago

Test scenario:

Official MQTT protocol (http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/csprd02/mqtt-v3.1.1-csprd02.html#_Toc385349800) states the following:

Non normative examples If a subscribing Client has been granted maximum QoS 1 for a particular Topic Filter, then a QoS 0 Application Message matching the filter is delivered to the Client at QoS 0. This means that at most one copy of the message is received by the Client. On the other hand a QoS 2 Message published to the same topic is downgraded by the Server to QoS 1 for delivery to the Client, so that Client might receive duplicate copies of the Message.

Is this Mosca behavior known, or by accident?

Even though the quoted example is non-normative the subscriber receives the message with upgraded QoS from the one publisher sent. In this case, messages that are not critical are getting queued on broker (QoS0 to QoS1).

For example (comparison), EMQ broker sends message to both clients with QoS0. (tested) Not sure, but HiveMQ should work same as EMQ - QoS can only be downgraded.