v3.1.1和v5.0之间的差异 - Youjingyu/mqtt.github.io GitHub Wiki
MQTT规范的3.1.1与5.0版之间的差异:
Differences between versions 3.1.1 and 5.0 of the MQTT specification:
3.1.1规范: http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html
3.1.1 specification: http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html
5.0规范: http://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html (pages 135/ 136)
5.0 specification: http://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html (pages 135/ 136)
- Session过期:将清理会话标志(Clean Session flag)拆分为清理启动标志(Clean Start flag)和会话有效期间隔( Session Expiry interval),清理启动标志指示会话应当在不使用现有会话的情况下启动,会话有效期间隔表示断开后保留会话的时间。 会话有效期间隔可以在断开时修改。 将清理开始标志设置为1并将会话有效期间隔设置为0,等效于在MQTT v3.1.1中将清理会话标志设置为1。
- Session expiry: Split the Clean Session flag into a Clean Start flag which indicates that the session should start without using an existing session, and a Session Expiry interval which says how long to retain the session after a disconnect. The session expiry interval can be modified at disconnect. Setting of Clean Start to 1 and Session Expiry Interval to 0 is equivalent in MQTT v3.1.1 of setting Clean Session to 1.
- 消息过期:发布消息时允许设置到期时间间隔。
- Message expiry: Allow an expiry interval to be set when a message is published.
- 所有ACK的原因码:将所有响应数据包修改为包含原因码。包括CONNACK, PUBACK, PUBREC, PUBREL, PUBCOMP, SUBACK, UNSUBACK, DISCONNECT, 和 AUTH。 这允许调用者确定所请求的函数是否成功。
- Reason code on all ACKs: Change all response packets to contain a reason code. This include CONNACK, PUBACK, PUBREC, PUBREL, PUBCOMP, SUBACK, UNSUBACK, DISCONNECT, and AUTH. This allows the invoker to determine whether the requested function succeeded.
- 所有ACK的原因字符:将大多数包含包含原因码的数据包,修改为允许可选的原因字符。这是设计来确定问题的,并不打算由接收者解析。
- Reason string on all ACKs: Change most packets with a reason code to also allow an optional reason string. This is designed for problem determination and is not intended to be parsed by the receiver.
- 服务器断开:允许服务器发送DISCONNECT以指示连接关闭的原因。
- Server disconnect: Allow DISCONNECT to be sent by the Server to indicate the reason the connection is closed.
- 有效载荷格式与内容类型:发布消息时,允许指定有效载荷的格式(二进制、文本),以及MIME格式的内容类型。并转发这些内容给消息的接收者。
- Payload format and content type: Allow the payload format (binary, text) and a MIME style content type to be specified when a message is published. These are forwarded on to the receiver of the message.
- 请求/响应:格式化MQTT中的请求/响应模式,并且提供响应主题和关联数据属性,以允许将响应消息发送回请求的发布者。另外,添加客户端从服务器获取配置信息的能力,以了解如何构建响应主题。
- Request / Response: Formalize the request/response pattern within MQTT and provide the Response Topic and Correlation Data properties to allow response messages to be routed back to the publisher of a request. Also, add the ability for the Client to get configuration information from the Server about how to construct the response topics.
- 共享订阅:支持共享订阅,以允许负载均衡订阅的消费者
- Shared Subscriptions: Add shared subscription support allowing for load balanced consumers of a subscription
- 订阅ID:允许在SUBSCRIBE中指定数字订阅标识符,并在发送消息(PUBLISH)时将其返回。 这允许客户端确定收到的消息来自哪个订阅或哪些订阅。
- Subscription ID: Allow a numeric subscription identifier to be specified on a SUBSCRIBE, and returned on the message when it is delivered. This allows the Client to determine which subscription or subscriptions caused the message to be delivered.
- 主题别名:允许将主题名缩写为一个小整数,从而减少MQTT数据包的大小。 客户端和服务器分别指定它们允许的主题别名数量。
- Topic Alias: Decrease the size of the MQTT packet overhead by allowing the topic name to be abbreviated to a small integer. The Client and Server independently specify how many topic aliases they allow.
- 流量控制:允许客户端和服务器分别指定它们允许的未完成可靠消息的数量(QoS> 0)。 发送者暂停发送这类消息以保持低于此指标。 这用于限制可靠消息的速率,并限制有多少消息同时发送。
- Flow control: Allow the Client and Server to independently specify the number of outstanding reliable messages (QoS>0) they allow. The sender pauses sending such messages to stay below this quota. This is used to limit the rate of reliable messages, and to limit how many are in flight at one time.
- 用户属性:为大多数数据包添加用户属性。 PUBLISH中的用户属性包含在消息中,并由客户端应用程序定义。 PUBLISH和Will Properties(遗嘱属性)上的用户属性由服务器转发给消息的接收者。 CONNECT,SUBSCRIBE和UNSUBSCRIBE数据包中的用户属性由服务器定义。 CONNACK PUBACK,PUBREC,PUBREL,PUBCOMP,SUBACK,UNSUBACK和AUTH数据包中的用户属性由发送者定义,并且对发送者的实现是唯一的。 用户属性的含义不由MQTT定义。
- User properties: Add User Properties to most packets. User properties on PUBLISH are included with the message and are defined by the Client applications. The user properties on PUBLISH and Will Properties are forwarded by the Server to the receiver of the message. User properties on the CONNECT, SUBSCRIBE, and UNSUBSCRIBE packets are defined by the Server implementation. The user properties on CONNACK PUBACK, PUBREC, PUBREL, PUBCOMP, SUBACK, UNSUBACK and AUTH packets are defined by the sender, and are unique to the sender implementation. The meaning of user properties is not defined by MQTT.
- 最大包体积:允许客户端和服务器分别指定它们支持的最大的数据包体积。 会话方发送超过最大体积的数据包会报错。
- Maximum Packet Size: Allow the Client and Server to independently specify the maximum packet size they support. It is an error for the session partner to send a larger packet.
- 可选的服务器可用功能:定义服务器不允许的一组功能,并提供一个机制,让服务器将不允许的功能指定给客户端。 可以通过这种方式指定的功能包括:最大的QoS,Retain可用性,可用的通配符订阅,可用的订阅标识符以及可用的共享订阅。 客户端使用服务器声明的不可用功能时会报错。 在MQTT的早期版本中,可以通过通知客户端未被授权使用某一功能,来达到服务器不实现某一功能的目的。 这一特性允许声明这类可选功能,并在客户使用这些功能时,添加特定的原因码。
- Optional Server feature availability: Define a set of features which the Server does not allow and provide a mechanism for the Server to specify this to the Client. The features which can be specified in this way are: Maximum QoS, Retain Available, Wildcard Subscription Available, Subscription Identifier Available, and Shared Subscription Available. It is an error for the Client to use features that the Server has declared are not available. It is possible in earlier versions of MQTT for a Server to not implement a feature by declaring that the Client is not authorized for that function. This feature allows such optional behavior to be declared and adds specific Reason Codes when the Client uses one of these features anyway.
- 增强验证:提供一种机制来启用质询/响应式认证,包括相互认证。 如果客户端和服务器都支持,允许使用SASL格式的身份验证,并且使客户端具有在连接内重新进行身份验证的能力。
- Enhanced authentication: Provide a mechanism to enable challenge/response style authentication including mutual authentication. This allows SASL style authentication to be used if supported by both Client and Server, and includes the ability for a Client to re-authenticate within a connection.
- 订阅选项:提供订阅选项,这些选项主要为允许消息桥应用程序而定义,包括不发送源于此客户端的消息(noLocal)的选项以及处理订阅中的保留(retain)消息的选项。
- Subscription options: Provide subscription options primarily defined to allow for message bridge applications. These include an option to not send messages originating on this Client (noLocal), and options for handling retained messages on subscribe.
- 遗嘱延迟:添加指定连接结束和发送遗嘱消息之间延迟的能力。 这样做的目的是,如果重新建立与该会话的连接,则不会发送遗嘱消息。 这可以在不通知其他人的情况下短暂中断连接。
- Will delay: Add the ability to specify a delay between the end of the connection and sending the will message. This is designed so that if a connection to the session is re-established then the will message is not sent. This allows for brief interruptions of the connection without notification to others.
- 服务器保活:允许服务器指定它希望客户端用作保持活动(时间)的值。 这使服务器可以设置一个允许的最大存活时间,并且仍然让客户端遵守它。
- Server Keep Alive: Allow the Server to specify the value it wishes the Client to use as a keep alive. This allows the Server to set a maximum allowed keepalive and still have the Client honor it.
- 分配ClientID(客户端ID):在ClientID由服务器分配的情况下,返回分配的ClientID。 这也避免了服务器分配的ClientID只能与Clean Session = 1的连接一起使用的限制。
- Assigned ClientID: In cases where the ClientID is assigned by the Server, return the assigned ClientID. This also lifts the restriction that Server assigned ClientIDs can only be used with Clean Session=1 connections.
- 服务器参考:允许服务器指定CONNACK或DISCONNECT使用的备用服务器。 这可以用作重定向或进行配置。
- Server reference: Allow the Server to specify an alternate Server to use on CONNACK or DISCONNECT. This can be used as a redirect or to do provisioning.