MQTT 更高的订阅者 QoS [英] MQTT higher QoS on subscriber

查看:121
本文介绍了MQTT 更高的订阅者 QoS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个发布者以 QoS 1(至少一次交付)向我的 MQTT 代理发送消息,而一个订阅者以 QoS 2(恰好一次交付)向我的 MQTT 代理发送消息,那么订阅者是否仍可能收到重复的消息?

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?

我担心的是,发布者可能会向代理发送重复的消息(因为 QoS 1 表明这是可能的),然后代理会将它们全部视为不同的消息并将它们全部转发给订阅者.这是 MQTT 代理的工作方式吗?或者他们是否足够聪明以意识到从发布者收到的重复消息都是相同的,然后只将一条转发给订阅者.

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.

推荐答案

QoS 级别介于单个客户端和代理之间.订阅者还会请求 QoS 级别,并且代理会授予订阅者最大订阅的 QoS.

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.

v3.1.1 的 MQTT 规范涵盖了这些不同的 QoS 级别如何与您在 第 3.8.4 节:

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

响应订阅而发送的有效载荷消息的 QoS 必须是原始发布消息的 QoS 和服务器授予的最大 QoS 中的最小值.

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.

订阅者在订阅主题时可能已被授予 最大 QoS 2.但是原始发布者使用 QoS 1.因此订阅者可能会收到原始发布者发送的消息的副本.

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.

这篇关于MQTT 更高的订阅者 QoS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆