MQTT higher QoS on subscriber

ぐ巨炮叔叔 提交于 2021-01-28 01:02:19

问题


If I have a publisher sending a message to my MQTT broker with QoS 1 (at least once delivery) and a subscriber with QoS 2 (exactly once delivery), is it possible for the subscriber to still receive duplicate messages?

My concern is that the publisher could send duplicate messages to the broker (since QoS 1 states that is possible) and then the broker would view them all as different messages and forward all of them on to the subscriber. Is this how MQTT brokers work? Or are they smart enough to realize the duplicate messages received from the publisher are all the same and then just forward one on to the subscriber.


回答1:


The QoS level is between individual clients and the broker. Subscribers also request a QoS level and the broker grants the subscriber a maximum QoS for a subscription.

The MQTT Spec for v3.1.1 covers how these different QoS levels relate for your example in section 3.8.4:

The QoS of Payload Messages sent in response to a Subscription MUST be the minimum of the QoS of the originally published message and the maximum QoS granted by the Server.

The subscriber might have been granted a maximum of QoS 2 when it subscribed to the topic. But the original publisher uses QoS 1. So the subscriber could receive duplicates of the message that the original publisher sent.



来源:https://stackoverflow.com/questions/55618335/mqtt-higher-qos-on-subscriber

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!