[{"data":1,"prerenderedAt":2242},["Reactive",2],{"VEb9Nnn1YX":3,"blog-post-zh-demonstrate-mqtt-5-0-features-using-mqttx-cli":26,"blog-posts-zh":2020},{"items":4,"meta":23},[5,8,11,14,17,20],{"title":6,"titleUrl":7},"如何在 Python3 中使用 MQTT 客户端库 Paho Client","how-to-use-mqtt-in-python",{"title":9,"titleUrl":10},"MQTT服务器（MQTT Broker）：工作原理与快速入门指南","the-ultimate-guide-to-mqtt-broker-comparison",{"title":12,"titleUrl":13},"MQTT QoS 0、1、2 解析：快速入门指南","introduction-to-mqtt-qos",{"title":15,"titleUrl":16},"在 ESP32 上使用 MQTT：入门指南","esp32-connects-to-the-free-public-mqtt-broker",{"title":18,"titleUrl":19},"MQTT 主题与通配符（Topics & Wildcards）入门手册","advanced-features-of-mqtt-topics",{"title":21,"titleUrl":22},"车联网 CAN Bus 协议介绍与数据实时流处理","can-bus-how-it-works-pros-and-cons",{"count":24,"limit":24,"page":25},6,1,{"slug":27,"title":28,"description":29,"date":30,"category":31,"cover":32,"version":-1,"coverWidth":-1,"coverHeight":-1,"updated":-1,"tags":33,"readingTime":36,"doc":37},"demonstrate-mqtt-5-0-features-using-mqttx-cli","探索 MQTT 5.0 新特性：基于 MQTTX CLI 的使用示例","为了让大家更全面地了解 MQTT 5.0，本文将依次介绍 5.0 引入的各个新特性，并使用 MQTTX CLI 工具演示我们应该如何在 EMQX 中使用这些特性，你可以通过复制和粘贴命令轻松地运行本文中的示例。","2023-08-23","guides","https://assets.emqx.com/images/35e43ae683c590cf512c62cf11a7e8cd.png",[34,35],"MQTT 5.0","CLI",17,{"_path":38,"_dir":39,"_draft":40,"_partial":40,"_locale":41,"title":28,"description":29,"date":42,"category":31,"tags":43,"cover":32,"body":44,"_type":2013,"_id":2014,"_source":2015,"_file":2016,"_extension":2017,"readingTime":36,"sitemap":2018},"/blog/zh/demonstrate-mqtt-5-0-features-using-mqttx-cli","zh",false,"","2023-08-23T00:00:00.000Z",[34,35],{"type":45,"children":46,"toc":1954},"root",[47,65,87,92,147,154,159,173,178,185,190,198,203,211,216,224,230,251,256,267,272,280,286,291,296,301,306,311,316,324,329,337,342,350,355,360,368,373,381,387,392,397,415,420,425,433,438,446,451,458,464,469,474,479,486,491,499,504,512,517,525,530,537,543,548,561,566,571,579,591,599,604,612,618,623,628,633,638,643,651,664,672,677,685,690,698,703,711,716,724,730,735,748,753,765,773,784,791,803,811,824,832,845,853,861,874,882,888,893,898,919,927,939,947,965,973,981,987,992,997,1002,1007,1026,1034,1040,1045,1050,1056,1061,1075,1080,1085,1090,1098,1103,1111,1116,1124,1130,1135,1140,1145,1150,1158,1163,1171,1176,1184,1189,1197,1202,1210,1223,1231,1236,1254,1259,1264,1272,1277,1284,1289,1297,1302,1309,1315,1320,1349,1354,1359,1364,1372,1376,1383,1388,1396,1401,1408,1413,1420,1425,1431,1436,1472,1486,1492,1506,1514,1519,1527,1533,1538,1546,1551,1559,1564,1572,1577,1585,1591,1596,1604,1609,1617,1622,1627,1635,1639,1644,1652,1656,1663,1669,1674,1679,1684,1689,1697,1702,1710,1715,1723,1728,1733,1740,1745,1753,1758,1764,1769,1774,1782,1787,1795,1801,1806,1811,1816,1834,1839,1847,1851,1858,1863,1871,1876,1883,1889,1894,1899,1903,1910,1915,1923,1928,1935,1940],{"type":48,"tag":49,"props":50,"children":51},"element","p",{},[52,63],{"type":48,"tag":53,"props":54,"children":59},"a",{"href":55,"rel":56,"target":58},"https://www.emqx.com/zh/blog/the-easiest-guide-to-getting-started-with-mqtt",[57,57],"noopener","_blank",[60],{"type":61,"value":62},"text","MQTT",{"type":61,"value":64}," 作为目前物联网领域最为流行的通信协议，它的最新版本早已在 2019 年就已经来到了 5.0。与之前的版本相比，5.0 增加了会话过期、原因码、共享订阅、请求响应等更符合现代物联网应用需求的特性，这也让它成为了目前绝大多数物联网企业的首选版本。",{"type":48,"tag":49,"props":66,"children":67},{},[68,70,76,78,85],{"type":61,"value":69},"为了让大家更全面地了解 MQTT 5.0，本文将依次介绍 5.0 引入的各个新特性，并使用 ",{"type":48,"tag":53,"props":71,"children":73},{"href":72},"/zh",[74],{"type":61,"value":75},"MQTTX CLI",{"type":61,"value":77}," 工具演示我们应该如何在 ",{"type":48,"tag":53,"props":79,"children":82},{"href":80,"rel":81,"target":58},"https://github.com/emqx/emqx",[57,57],[83],{"type":61,"value":84},"EMQX",{"type":61,"value":86}," 中使用这些特性，你可以通过复制和粘贴命令轻松地运行本文中的示例。",{"type":48,"tag":49,"props":88,"children":89},{},[90],{"type":61,"value":91},"在正式开始前，我们需要完成以下准备工作：",{"type":48,"tag":93,"props":94,"children":95},"ol",{},[96,112,124],{"type":48,"tag":97,"props":98,"children":99},"li",{},[100,102],{"type":61,"value":101},"使用 Docker 来部署一个最基础的 EMQX 实例，你可以运行以下命令来启动 EMQX：",{"type":48,"tag":103,"props":104,"children":106},"pre",{"code":105},"docker run -d --name emqx -p 18083:18083 -p 1883:1883 emqx:5.1.3\n",[107],{"type":48,"tag":108,"props":109,"children":110},"code",{"__ignoreMap":41},[111],{"type":61,"value":105},{"type":48,"tag":97,"props":113,"children":114},{},[115,117,122],{"type":61,"value":116},"下载并安装 ",{"type":48,"tag":53,"props":118,"children":120},{"href":119},"/zh/downloads",[121],{"type":61,"value":75},{"type":61,"value":123}," 1.9.4。它是一款开源的 MQTT 5.0 命令行客户端工具，我们将通过它来完成本文的所有示例。",{"type":48,"tag":97,"props":125,"children":126},{},[127,129,136,138,145],{"type":61,"value":128},"安装 ",{"type":48,"tag":53,"props":130,"children":133},{"href":131,"rel":132,"target":58},"https://www.wireshark.org/",[57,57],[134],{"type":61,"value":135},"Wireshark",{"type":61,"value":137},"。在部分示例中，我们将用它来抓取并分析一些 ",{"type":48,"tag":53,"props":139,"children":142},{"href":140,"rel":141,"target":58},"https://www.emqx.com/zh/blog/introduction-to-mqtt-control-packets",[57,57],[143],{"type":61,"value":144},"MQTT 报文",{"type":61,"value":146},"，这可以帮助我们更好地了解究竟发生了什么。",{"type":48,"tag":148,"props":149,"children":151},"h2",{"id":150},"特性-1会话过期",[152],{"type":61,"value":153},"特性 1：会话过期",{"type":48,"tag":49,"props":155,"children":156},{},[157],{"type":61,"value":158},"在 MQTT 5.0 中，客户端可以在 CONNECT 报文中通过 Session Expiry Interval 来指示它期望的网络连接断开后会话的过期间隔（以秒为单位）。如果服务端不接受这个过期间隔，也可以在 CONNACK 报文中指示一个新的过期间隔，客户端则需要遵从服务端的要求。",{"type":48,"tag":49,"props":160,"children":161},{},[162,164,171],{"type":61,"value":163},"在会话过期之前，",{"type":48,"tag":53,"props":165,"children":168},{"href":166,"rel":167,"target":58},"https://www.emqx.com/zh/blog/mqtt-client-tools",[57,57],[169],{"type":61,"value":170},"MQTT 客户端",{"type":61,"value":172},"与服务端都需要存储相应的会话状态。以服务端为例，它需要存储的会话状态包括已经发送但尚未完成确认的消息，尚未发送的消息以及客户端的订阅列表等等。",{"type":48,"tag":49,"props":174,"children":175},{},[176],{"type":61,"value":177},"只要客户端与服务端的连接在会话过期前恢复，那么它们就可以继续之前的通信，就像连接从未断开过一样。",{"type":48,"tag":179,"props":180,"children":182},"h3",{"id":181},"示例-1",[183],{"type":61,"value":184},"示例 1",{"type":48,"tag":49,"props":186,"children":187},{},[188],{"type":61,"value":189},"客户端 sub1 订阅主题 t1，并设置会话过期间隔为 60 秒，订阅完成后在终端输入 Ctrl+C 断开客户端连接：",{"type":48,"tag":103,"props":191,"children":193},{"code":192},"mqttx sub --client-id sub1 --session-expiry-interval 60 --topic t1\n…  Connecting...\n✔  Connected\n…  Subscribing to t1...\n✔  Subscribed to t1\n^C\n",[194],{"type":48,"tag":108,"props":195,"children":196},{"__ignoreMap":41},[197],{"type":61,"value":192},{"type":48,"tag":49,"props":199,"children":200},{},[201],{"type":61,"value":202},"在 60 秒内向主题 t1 发布一条消息：",{"type":48,"tag":103,"props":204,"children":206},{"code":205},"mqttx pub --topic t1 --message \"Hello World\"\n…  Connecting...\n✔  Connected\n…  Message publishing...\n✔  Message published\n",[207],{"type":48,"tag":108,"props":208,"children":209},{"__ignoreMap":41},[210],{"type":61,"value":205},{"type":48,"tag":49,"props":212,"children":213},{},[214],{"type":61,"value":215},"客户端 sub1 重新连接，注意这里指定了 --no-clean 选项表示希望复用之前的会话，我们将看到此客户端收到了我们在它连接之前发布的消息：",{"type":48,"tag":103,"props":217,"children":219},{"code":218},"mqttx sub --client-id sub1 --no-clean --session-expiry-interval 0 --topic t1\n…  Connecting...\n✔  Connected\n…  Subscribing to t1...\npayload: Hello World\n✔  Subscribed to t1\n",[220],{"type":48,"tag":108,"props":221,"children":222},{"__ignoreMap":41},[223],{"type":61,"value":218},{"type":48,"tag":179,"props":225,"children":227},{"id":226},"示例-2",[228],{"type":61,"value":229},"示例 2",{"type":48,"tag":49,"props":231,"children":232},{},[233,235,241,243,249],{"type":61,"value":234},"EMQX 默认允许的最大会话过期间隔为 2 小时，我们可以打开 EMQX Dashboard（浏览器中输入 ",{"type":48,"tag":108,"props":236,"children":238},{"className":237},[],[239],{"type":61,"value":240},"http://localhost:18083",{"type":61,"value":242}," 即可访问），通过 ",{"type":48,"tag":108,"props":244,"children":246},{"className":245},[],[247],{"type":61,"value":248},"Management -> MQTT Settings -> Session",{"type":61,"value":250}," 页面中的 Session Expiry Interval 配置项来修改它。",{"type":48,"tag":49,"props":252,"children":253},{},[254],{"type":61,"value":255},"本示例中我们将它设置为 0 秒，即会话将在网络连接断开时立即过期：",{"type":48,"tag":49,"props":257,"children":258},{},[259],{"type":48,"tag":260,"props":261,"children":266},"img",{"alt":262,"src":263,"loading":264,"decoding":265},"MQTT Session Expiry Interval","https://assets.emqx.com/images/84a3d445ad64b2bb5c0ac0d7575637cf.png?x-image-process=image/resize,w_1520/format,webp","lazy","async",[],{"type":48,"tag":49,"props":268,"children":269},{},[270],{"type":61,"value":271},"接下来，重复示例 1 中的步骤，这一次客户端 sub1 将不会在重新连接后收到消息：",{"type":48,"tag":103,"props":273,"children":275},{"code":274},"mqttx sub --client-id sub1 --session-expiry-interval 60 --topic t1\n…  Connecting...\n✔  Connected\n…  Subscribing to t1...\n✔  Subscribed to t1\n^C\n\nmqttx pub --topic t1 --message \"Hello World\"\n…  Connecting...\n✔  Connected\n…  Message publishing...\n✔  Message published\n\nmqttx sub --client-id sub1 --no-clean --session-expiry-interval 0 --topic t1\n…  Connecting...\n✔  Connected\n…  Subscribing to t1...\n✔  Subscribed to t1\n",[276],{"type":48,"tag":108,"props":277,"children":278},{"__ignoreMap":41},[279],{"type":61,"value":274},{"type":48,"tag":148,"props":281,"children":283},{"id":282},"特性-2消息过期",[284],{"type":61,"value":285},"特性 2：消息过期",{"type":48,"tag":49,"props":287,"children":288},{},[289],{"type":61,"value":290},"在 MQTT 5.0 中，我们可以为每条消息设置一个过期间隔（以秒为单位），如果消息在服务端中停留超过了这个间隔，那么它将不会再被分发给客户端。",{"type":48,"tag":49,"props":292,"children":293},{},[294],{"type":61,"value":295},"当我们想要长时间地保留会话，但是又想要发送一些具有时效性的消息时，这个特性将会非常有用。",{"type":48,"tag":49,"props":297,"children":298},{},[299],{"type":61,"value":300},"另外，如果客户端在发布消息时设置了过期间隔，那么服务端在转发这个消息时也会包含过期间隔，但过期间隔的值会被更新为服务端接收到的值减去该消息在服务端停留的时间。",{"type":48,"tag":49,"props":302,"children":303},{},[304],{"type":61,"value":305},"这样接收者就可以知道这个消息是有时效的，以及它将在多少时间后过期。",{"type":48,"tag":179,"props":307,"children":309},{"id":308},"示例-1-1",[310],{"type":61,"value":184},{"type":48,"tag":49,"props":312,"children":313},{},[314],{"type":61,"value":315},"客户端 sub2 订阅主题 t2，并设置会话过期间隔为 300 秒，订阅完成后在终端输入 Ctrl+C 断开客户端连接：",{"type":48,"tag":103,"props":317,"children":319},{"code":318},"mqttx sub --client-id sub2 --session-expiry-interval 300 --topic t2\n…  Connecting...\n✔  Connected\n…  Subscribing to t2...\n✔  Subscribed to t2\n^C\n",[320],{"type":48,"tag":108,"props":321,"children":322},{"__ignoreMap":41},[323],{"type":61,"value":318},{"type":48,"tag":49,"props":325,"children":326},{},[327],{"type":61,"value":328},"向同一主题发布一条消息，并设置消息过期间隔为 5 秒钟",{"type":48,"tag":103,"props":330,"children":332},{"code":331},"mqttx pub --topic t2 --message \"Hello World\" --message-expiry-interval 5\n…  Connecting...\n✔  Connected\n…  Message publishing...\n✔  Message published\n",[333],{"type":48,"tag":108,"props":334,"children":335},{"__ignoreMap":41},[336],{"type":61,"value":331},{"type":48,"tag":49,"props":338,"children":339},{},[340],{"type":61,"value":341},"等待 10 秒钟后客户端 sub2 恢复连接，但是它将不会收到我们刚刚发布的消息：",{"type":48,"tag":103,"props":343,"children":345},{"code":344},"sleep 10; mqttx sub --client-id sub2 --no-clean --session-expiry-interval 300 --topic t2\n…  Connecting...\n✔  Connected\n…  Subscribing to t2...\n✔  Subscribed to t2\n",[346],{"type":48,"tag":108,"props":347,"children":348},{"__ignoreMap":41},[349],{"type":61,"value":344},{"type":48,"tag":179,"props":351,"children":353},{"id":352},"示例-2-1",[354],{"type":61,"value":229},{"type":48,"tag":49,"props":356,"children":357},{},[358],{"type":61,"value":359},"继续向主题 t2 发布消息，并设置消息过期间隔为 60 秒钟：",{"type":48,"tag":103,"props":361,"children":363},{"code":362},"mqttx pub --topic t2 --message \"Hello World\" --message-expiry-interval 60\n…  Connecting...\n✔  Connected\n…  Message publishing...\n✔  Message published\n",[364],{"type":48,"tag":108,"props":365,"children":366},{"__ignoreMap":41},[367],{"type":61,"value":362},{"type":48,"tag":49,"props":369,"children":370},{},[371],{"type":61,"value":372},"等待 10 秒后客户端 sub2 恢复连接，它将收到我们刚刚发布的消息，并且其中的消息过期间隔为 50 秒。",{"type":48,"tag":103,"props":374,"children":376},{"code":375},"sleep 10; mqttx sub --client-id sub2 --no-clean --session-expiry-interval 0 --topic t2 --output-mode clean\n{\n  \"topic\": \"t2\",\n  \"payload\": \"Hello World\",\n  \"packet\": {\n      ...\n    \"properties\": {\n      \"messageExpiryInterval\": 50\n    }\n  }\n}\n",[377],{"type":48,"tag":108,"props":378,"children":379},{"__ignoreMap":41},[380],{"type":61,"value":375},{"type":48,"tag":148,"props":382,"children":384},{"id":383},"特性-3令所有响应报文支持原因码",[385],{"type":61,"value":386},"特性 3：令所有响应报文支持原因码",{"type":48,"tag":49,"props":388,"children":389},{},[390],{"type":61,"value":391},"MQTT 5.0 不仅为所有响应报文都增加了原因码字段，同时也扩展了可用的原因码。现在服务端和客户端都可以更清晰地向对方指示错误原因。",{"type":48,"tag":49,"props":393,"children":394},{},[395],{"type":61,"value":396},"比如当消息到达但当前不存在任何匹配的订阅时，服务端将会丢弃这个消息。但为了让消息的发送者得知这一情况，服务端会将响应报文中的原因码设置为 0x10（仅限 QoS 1 与 QoS 2 消息），表示不存在匹配的订阅者。",{"type":48,"tag":398,"props":399,"children":400},"blockquote",{},[401],{"type":48,"tag":49,"props":402,"children":403},{},[404,406,413],{"type":61,"value":405},"你可以通过 ",{"type":48,"tag":53,"props":407,"children":410},{"href":408,"rel":409,"target":58},"https://www.emqx.com/zh/blog/mqtt5-new-features-reason-code-and-ack",[57,57],[411],{"type":61,"value":412},"MQTT 5.0 Reason Code 速查表",{"type":61,"value":414}," 了解更多原因码相关的知识。",{"type":48,"tag":179,"props":416,"children":418},{"id":417},"示例",[419],{"type":61,"value":417},{"type":48,"tag":49,"props":421,"children":422},{},[423],{"type":61,"value":424},"本示例中我们将用到 Wireshark。启动 Wireshark 后首先选择正确的网卡，如果你的 EMQX 与 MQTTX CLI 同样运行在同一台机器上，那么你应该与本示例一样选择环回接口，然后输入以下过滤语句抓取报文：",{"type":48,"tag":103,"props":426,"children":428},{"code":427},"tcp.port == 1883\n",[429],{"type":48,"tag":108,"props":430,"children":431},{"__ignoreMap":41},[432],{"type":61,"value":427},{"type":48,"tag":49,"props":434,"children":435},{},[436],{"type":61,"value":437},"向主题 t3 发布 QoS 1 消息：",{"type":48,"tag":103,"props":439,"children":441},{"code":440},"mqttx pub --topic t3 --message \"Hello World\" --qos 1\n…  Connecting...\n✔  Connected\n…  Message publishing...\n✔  Message published\n",[442],{"type":48,"tag":108,"props":443,"children":444},{"__ignoreMap":41},[445],{"type":61,"value":440},{"type":48,"tag":49,"props":447,"children":448},{},[449],{"type":61,"value":450},"在 Wireshark 中我们将看到 EMQX 返回的 PUBACK 报文中 Reason Code 被设置为 0x10：",{"type":48,"tag":49,"props":452,"children":453},{},[454],{"type":48,"tag":260,"props":455,"children":457},{"alt":135,"src":456,"loading":264,"decoding":265},"https://assets.emqx.com/images/dc6b0ade500c1df276114bd14d4792fe.png?x-image-process=image/resize,w_1520/format,webp",[],{"type":48,"tag":148,"props":459,"children":461},{"id":460},"特性-4服务器断开",[462],{"type":61,"value":463},"特性 4：服务器断开",{"type":48,"tag":49,"props":465,"children":466},{},[467],{"type":61,"value":468},"MQTT 5.0 允许服务端在断开网络连接前发送 DISCONNECT 报文，以便向客户端指示连接断开的原因。",{"type":48,"tag":179,"props":470,"children":472},{"id":471},"示例-3",[473],{"type":61,"value":417},{"type":48,"tag":49,"props":475,"children":476},{},[477],{"type":61,"value":478},"在 Wireshark 中输入以下过滤语句抓取报文：",{"type":48,"tag":103,"props":480,"children":481},{"code":427},[482],{"type":48,"tag":108,"props":483,"children":484},{"__ignoreMap":41},[485],{"type":61,"value":427},{"type":48,"tag":49,"props":487,"children":488},{},[489],{"type":61,"value":490},"建立一个 MQTT 连接：",{"type":48,"tag":103,"props":492,"children":494},{"code":493},"mqttx conn --client-id conn4\n…  Connecting...\n✔  Connected\n",[495],{"type":48,"tag":108,"props":496,"children":497},{"__ignoreMap":41},[498],{"type":61,"value":493},{"type":48,"tag":49,"props":500,"children":501},{},[502],{"type":61,"value":503},"在另一个终端窗口中使用 EMQX 提供的 CLI 命令手动踢除客户端：",{"type":48,"tag":103,"props":505,"children":507},{"code":506},"docker exec emqx emqx ctl clients kick conn4\nok\n",[508],{"type":48,"tag":108,"props":509,"children":510},{"__ignoreMap":41},[511],{"type":61,"value":506},{"type":48,"tag":49,"props":513,"children":514},{},[515],{"type":61,"value":516},"我们将在第一个终端窗口中看到连接被断开：",{"type":48,"tag":103,"props":518,"children":520},{"code":519},"✖  Connection closed\n",[521],{"type":48,"tag":108,"props":522,"children":523},{"__ignoreMap":41},[524],{"type":61,"value":519},{"type":48,"tag":49,"props":526,"children":527},{},[528],{"type":61,"value":529},"EMQX 发送的 DISCONNECT 报文中 Reason Code 被设置为 0x98，表示此连接因为管理操作而被关闭：",{"type":48,"tag":49,"props":531,"children":532},{},[533],{"type":48,"tag":260,"props":534,"children":536},{"alt":135,"src":535,"loading":264,"decoding":265},"https://assets.emqx.com/images/05744c8ecd86b07215cff789c10425cb.png?x-image-process=image/resize,w_1520/format,webp",[],{"type":48,"tag":148,"props":538,"children":540},{"id":539},"特性-5载荷格式与内容类型",[541],{"type":61,"value":542},"特性 5：载荷格式与内容类型",{"type":48,"tag":49,"props":544,"children":545},{},[546],{"type":61,"value":547},"在 MQTT 5.0 中，消息的发布者可以通过 Payload Format Indicator 来指示该消息的内容是 UTF-8 编码的字符数据还是未指定格式的二进制数据。",{"type":48,"tag":49,"props":549,"children":550},{},[551,553,559],{"type":61,"value":552},"Content Type 则可以进一步指示消息内容的具体格式，这样接收者可以更容易地知道应该如何解析这个消息。常见的做法是将其设置为一个 MIME 内容类型，例如 ",{"type":48,"tag":108,"props":554,"children":556},{"className":555},[],[557],{"type":61,"value":558},"application/json",{"type":61,"value":560},"。当然这并不是强制的，我们也可以使用任意的 UTF-8 字符串来指示我们自定义的消息类型 。",{"type":48,"tag":179,"props":562,"children":564},{"id":563},"示例-4",[565],{"type":61,"value":417},{"type":48,"tag":49,"props":567,"children":568},{},[569],{"type":61,"value":570},"订阅主题 t6：",{"type":48,"tag":103,"props":572,"children":574},{"code":573},"mqttx sub --topic t6 --output-mode clean\n",[575],{"type":48,"tag":108,"props":576,"children":577},{"__ignoreMap":41},[578],{"type":61,"value":573},{"type":48,"tag":49,"props":580,"children":581},{},[582,584,589],{"type":61,"value":583},"在另一个终端窗口中发布消息，设置 Payload Format Indicator 表示此消息的内容是 UTF-8 编码的字符数据，设置为 Content Type 为 ",{"type":48,"tag":108,"props":585,"children":587},{"className":586},[],[588],{"type":61,"value":558},{"type":61,"value":590}," 表示这是一个 JSON 格式的消息：",{"type":48,"tag":103,"props":592,"children":594},{"code":593},"mqttx pub --topic t6 --message \"{\\\"content\\\": \\\"Hello World\\\"}\" --payload-format-indicator --content-type application/json\n…  Connecting...\n✔  Connected\n…  Message publishing...\n✔  Message published\n",[595],{"type":48,"tag":108,"props":596,"children":597},{"__ignoreMap":41},[598],{"type":61,"value":593},{"type":48,"tag":49,"props":600,"children":601},{},[602],{"type":61,"value":603},"第一个终端窗口将打印接收到的消息内容，我们可以看到消息中包含了 Content Type 和 Payload Format Indicator：",{"type":48,"tag":103,"props":605,"children":607},{"code":606},"{\n  \"topic\": \"t6\",\n  \"payload\": \"{\\\"content\\\": \\\"Hello World\\\"}\",\n  \"packet\": {\n        ...\n    \"properties\": {\n      \"contentType\": \"application/json\",\n      \"payloadFormatIndicator\": true\n    }\n  }\n}\n",[608],{"type":48,"tag":108,"props":609,"children":610},{"__ignoreMap":41},[611],{"type":61,"value":606},{"type":48,"tag":148,"props":613,"children":615},{"id":614},"特性-6请求响应",[616],{"type":61,"value":617},"特性 6：请求/响应",{"type":48,"tag":49,"props":619,"children":620},{},[621],{"type":61,"value":622},"MQTT 5.0 极大地改善了对请求响应模式的支持。请求方可以在请求消息指定响应主题（Response Topic），响应方则需要向该响应主题发布响应消息。",{"type":48,"tag":49,"props":624,"children":625},{},[626],{"type":61,"value":627},"这在同时存在多个请求方，响应方需要将响应正确地回复给其中一个请求方时非常有用，不同请求方只需要指定不同的响应主题即可。一个简单的做法是在响应主题中包含自己的 Client ID。",{"type":48,"tag":49,"props":629,"children":630},{},[631],{"type":61,"value":632},"MQTT 不能保证请求方的请求一定被响应方收到，反之亦然。所以请求方还需要能够正确地将自己发出的请求与收到的响应进行关联。在 MQTT 5.0 中，我们可以在请求消息中设置对比数据（Correlation Data），响应方将原封不动地在响应消息中返回这个对比数据，这样请求方就能够知道这是哪个请求的响应。",{"type":48,"tag":179,"props":634,"children":636},{"id":635},"示例-5",[637],{"type":61,"value":417},{"type":48,"tag":49,"props":639,"children":640},{},[641],{"type":61,"value":642},"在第一个终端窗口中，响应方订阅请求主题：",{"type":48,"tag":103,"props":644,"children":646},{"code":645},"mqttx sub --client-id responder --topic request --session-expiry-interval 300 --output-mode clean\n",[647],{"type":48,"tag":108,"props":648,"children":649},{"__ignoreMap":41},[650],{"type":61,"value":645},{"type":48,"tag":49,"props":652,"children":653},{},[654,656,662],{"type":61,"value":655},"在第二个终端窗口中，请求方发布请求消息，并设置响应主题为 ",{"type":48,"tag":108,"props":657,"children":659},{"className":658},[],[660],{"type":61,"value":661},"response/requester1",{"type":61,"value":663},"：",{"type":48,"tag":103,"props":665,"children":667},{"code":666},"mqttx pub --client-id requester1 --session-expiry-interval 300 --topic request --message \"This is a reuqest\" --response-topic response/requester1 --correlation-data request-1\n…  Connecting...\n✔  Connected\n…  Message publishing...\n✔  Message published\n",[668],{"type":48,"tag":108,"props":669,"children":670},{"__ignoreMap":41},[671],{"type":61,"value":666},{"type":48,"tag":49,"props":673,"children":674},{},[675],{"type":61,"value":676},"在第一个终端窗口中，响应方收到请求消息，消息中包含了响应主题与对比数据：",{"type":48,"tag":103,"props":678,"children":680},{"code":679},"{\n  \"topic\": \"request\",\n  \"payload\": \"This is a reuqest\",\n  \"packet\": {\n    \"properties\": {\n      \"correlationData\": {\n        \"type\": \"Buffer\",\n        \"data\": [\n          114,\n          101,\n          113,\n          117,\n          101,\n          115,\n          116,\n          45,\n          49\n        ]\n      },\n      \"responseTopic\": \"response/requester1\"\n    }\n  }\n}\n",[681],{"type":48,"tag":108,"props":682,"children":683},{"__ignoreMap":41},[684],{"type":61,"value":679},{"type":48,"tag":49,"props":686,"children":687},{},[688],{"type":61,"value":689},"回到第二个终端窗口，请求方订阅响应主题（在实际应用中，请求方需要在发布请求前订阅响应主题以免错过响应消息）：",{"type":48,"tag":103,"props":691,"children":693},{"code":692},"mqttx sub --client-id requester1 --no-clean --session-expiry-interval 300 --topic response/requester1 --output-mode clean\n",[694],{"type":48,"tag":108,"props":695,"children":696},{"__ignoreMap":41},[697],{"type":61,"value":692},{"type":48,"tag":49,"props":699,"children":700},{},[701],{"type":61,"value":702},"在第一个终端窗口中，响应方收到请求中的响应主题发布响应响应，并携带对比数据：",{"type":48,"tag":103,"props":704,"children":706},{"code":705},"mqttx pub --client-id responder --topic response/requester1 --message \"This is a response\" --correlation-data request-1\n",[707],{"type":48,"tag":108,"props":708,"children":709},{"__ignoreMap":41},[710],{"type":61,"value":705},{"type":48,"tag":49,"props":712,"children":713},{},[714],{"type":61,"value":715},"在第二个终端窗口中，请求方收到响应消息：",{"type":48,"tag":103,"props":717,"children":719},{"code":718},"{\n  \"topic\": \"response\",\n  \"payload\": \"This is a response\",\n  \"packet\": {\n      ...\n    \"properties\": {\n      \"correlationData\": {\n        \"type\": \"Buffer\",\n        \"data\": [\n          114,\n          101,\n          113,\n          117,\n          101,\n          115,\n          116,\n          45,\n          49\n        ]\n      }\n    }\n  }\n}\n",[720],{"type":48,"tag":108,"props":721,"children":722},{"__ignoreMap":41},[723],{"type":61,"value":718},{"type":48,"tag":148,"props":725,"children":727},{"id":726},"特性-7共享订阅",[728],{"type":61,"value":729},"特性 7：共享订阅",{"type":48,"tag":49,"props":731,"children":732},{},[733],{"type":61,"value":734},"MQTT 5.0 增加了对共享订阅的支持，使得订阅端能够以负载均衡的方式来消费消息。",{"type":48,"tag":49,"props":736,"children":737},{},[738,740,746],{"type":61,"value":739},"它允许我们将订阅客户端划分为多个订阅组，消息仍然会被转发给所有订阅组，但一个订阅组内的客户端将以随机、轮询等策略交替接收消息。这些策略完全由服务端实现，客户端不需要进行任何修改，唯一需要做的就是通过 ",{"type":48,"tag":108,"props":741,"children":743},{"className":742},[],[744],{"type":61,"value":745},"$share/{ShareGroup}/{Topic}",{"type":61,"value":747}," 来发起共享订阅。",{"type":48,"tag":179,"props":749,"children":751},{"id":750},"示例-6",[752],{"type":61,"value":417},{"type":48,"tag":49,"props":754,"children":755},{},[756,758,764],{"type":61,"value":757},"在第一个终端窗口中，订阅主题 ",{"type":48,"tag":108,"props":759,"children":761},{"className":760},[],[762],{"type":61,"value":763},"$share/g1/t7",{"type":61,"value":663},{"type":48,"tag":103,"props":766,"children":768},{"code":767},"mqttx sub --topic '$share/g1/t7'\n…  Connecting...\n✔  Connected\n…  Subscribing to $share/g1/t7...\n✔  Subscribed to $share/g1/t7\n",[769],{"type":48,"tag":108,"props":770,"children":771},{"__ignoreMap":41},[772],{"type":61,"value":767},{"type":48,"tag":49,"props":774,"children":775},{},[776,778,783],{"type":61,"value":777},"在第二个终端窗口中，同样订阅主题 ",{"type":48,"tag":108,"props":779,"children":781},{"className":780},[],[782],{"type":61,"value":763},{"type":61,"value":663},{"type":48,"tag":103,"props":785,"children":786},{"code":767},[787],{"type":48,"tag":108,"props":788,"children":789},{"__ignoreMap":41},[790],{"type":61,"value":767},{"type":48,"tag":49,"props":792,"children":793},{},[794,796,802],{"type":61,"value":795},"在第三个终端窗口中，改为订阅主题 ",{"type":48,"tag":108,"props":797,"children":799},{"className":798},[],[800],{"type":61,"value":801},"$share/g2/t7",{"type":61,"value":663},{"type":48,"tag":103,"props":804,"children":806},{"code":805},"mqttx sub --topic '$share/g2/t7'\n…  Connecting...\n✔  Connected\n…  Subscribing to $share/g2/t7...\n✔  Subscribed to $share/g2/t7\n",[807],{"type":48,"tag":108,"props":808,"children":809},{"__ignoreMap":41},[810],{"type":61,"value":805},{"type":48,"tag":49,"props":812,"children":813},{},[814,816,822],{"type":61,"value":815},"在第四个终端窗口中，向主题 t7 发布消息，这里我们使用了 ",{"type":48,"tag":108,"props":817,"children":819},{"className":818},[],[820],{"type":61,"value":821},"--multiline",{"type":61,"value":823}," 选项，以每次键入回车的方式发送多条消息：",{"type":48,"tag":103,"props":825,"children":827},{"code":826},"mqttx pub --topic t7 -s --stdin --multiline\n…  Connecting...\n✔  Connected, press Enter to publish, press Ctrl+C to exit\nMessage 1\nMessage 2\nMessage 3\nMessage 4\nMessage 5\nMessage 6\n^C\n",[828],{"type":48,"tag":108,"props":829,"children":830},{"__ignoreMap":41},[831],{"type":61,"value":826},{"type":48,"tag":49,"props":833,"children":834},{},[835,837,843],{"type":61,"value":836},"EMQX 默认的共享订阅策略为 ",{"type":48,"tag":108,"props":838,"children":840},{"className":839},[],[841],{"type":61,"value":842},"round_robin",{"type":61,"value":844},"，这表示消息将轮流分发给同一个订阅组内的订阅者。所以我们将看到第一个和第二个终端窗口中的订阅者将交替接收我们发布的消息：",{"type":48,"tag":103,"props":846,"children":848},{"code":847},"payload: Message 1\n\npayload: Message 3\n\npayload: Message 5\n",[849],{"type":48,"tag":108,"props":850,"children":851},{"__ignoreMap":41},[852],{"type":61,"value":847},{"type":48,"tag":103,"props":854,"children":856},{"code":855},"payload: Message 2\n\npayload: Message 4\n\npayload: Message 6\n",[857],{"type":48,"tag":108,"props":858,"children":859},{"__ignoreMap":41},[860],{"type":61,"value":855},{"type":48,"tag":49,"props":862,"children":863},{},[864,866,872],{"type":61,"value":865},"共享订阅组 ",{"type":48,"tag":108,"props":867,"children":869},{"className":868},[],[870],{"type":61,"value":871},"g2",{"type":61,"value":873}," 中只有一个订阅者，所以我们将在第三个终端窗口中看到订阅者收到了所有消息：",{"type":48,"tag":103,"props":875,"children":877},{"code":876},"payload: Message 1\n\npayload: Message 2\n\npayload: Message 3\n\npayload: Message 4\n\npayload: Message 5\n\npayload: Message 6\n",[878],{"type":48,"tag":108,"props":879,"children":880},{"__ignoreMap":41},[881],{"type":61,"value":876},{"type":48,"tag":148,"props":883,"children":885},{"id":884},"特性-8订阅标识符",[886],{"type":61,"value":887},"特性 8：订阅标识符",{"type":48,"tag":49,"props":889,"children":890},{},[891],{"type":61,"value":892},"MQTT 5.0 允许客户端在订阅时设置一个订阅标识符（Subscription Identifier），服务端会将该标识符与订阅绑定，当服务端向该订阅转发消息时，它会在消息中附上对应的标识符。客户端可以使用消息中的订阅标识符，决定触发哪一个回调，或者进行其他操作。",{"type":48,"tag":179,"props":894,"children":896},{"id":895},"示例-7",[897],{"type":61,"value":417},{"type":48,"tag":49,"props":899,"children":900},{},[901,903,909,911,917],{"type":61,"value":902},"同一个客户端订阅主题 ",{"type":48,"tag":108,"props":904,"children":906},{"className":905},[],[907],{"type":61,"value":908},"t8/1",{"type":61,"value":910}," 与 ",{"type":48,"tag":108,"props":912,"children":914},{"className":913},[],[915],{"type":61,"value":916},"t8/#",{"type":61,"value":918},"，并设置不同的订阅标识符：",{"type":48,"tag":103,"props":920,"children":922},{"code":921},"mqttx sub --client-id sub8 --session-expiry-interval 300 --topic t8/1 --subscription-identifier 1\n…  Connecting...\n✔  Connected\n…  Subscribing to t8/1...\n✔  Subscribed to t8/1\n^C\nmqttx sub --client-id sub8 --no-clean --session-expiry-interval 300 --topic t8/# --subscription-identifier 2 --output-mode clean\n",[923],{"type":48,"tag":108,"props":924,"children":925},{"__ignoreMap":41},[926],{"type":61,"value":921},{"type":48,"tag":49,"props":928,"children":929},{},[930,932,937],{"type":61,"value":931},"在第二个终端窗口中，向主题 ",{"type":48,"tag":108,"props":933,"children":935},{"className":934},[],[936],{"type":61,"value":908},{"type":61,"value":938}," 发布消息：",{"type":48,"tag":103,"props":940,"children":942},{"code":941},"mqttx pub --topic t8/1 --message \"Hello World\"\n",[943],{"type":48,"tag":108,"props":944,"children":945},{"__ignoreMap":41},[946],{"type":61,"value":941},{"type":48,"tag":49,"props":948,"children":949},{},[950,952,957,959,964],{"type":61,"value":951},"第一个终端窗口中的订阅端将收到两条消息，根据消息中的订阅标识符我们可以得知，第一条消息来自订阅的主题 ",{"type":48,"tag":108,"props":953,"children":955},{"className":954},[],[956],{"type":61,"value":916},{"type":61,"value":958},"，第二条消息来自订阅的主题 ",{"type":48,"tag":108,"props":960,"children":962},{"className":961},[],[963],{"type":61,"value":908},{"type":61,"value":663},{"type":48,"tag":103,"props":966,"children":968},{"code":967},"{\n  \"topic\": \"t8/1\",\n  \"payload\": \"Hello World\",\n  \"packet\": {\n        ...\n    \"properties\": {\n      \"subscriptionIdentifier\": 2\n    }\n  }\n}\n{\n  \"topic\": \"t8/1\",\n  \"payload\": \"Hello World\",\n  \"packet\": {\n        ...\n    \"properties\": {\n      \"subscriptionIdentifier\": 1\n    }\n  }\n}\n",[969],{"type":48,"tag":108,"props":970,"children":971},{"__ignoreMap":41},[972],{"type":61,"value":967},{"type":48,"tag":398,"props":974,"children":975},{},[976],{"type":48,"tag":49,"props":977,"children":978},{},[979],{"type":61,"value":980},"当消息匹配同一个客户端的多个订阅时，MQTT 服务端可以向这些重叠的订阅分别发送一条消息，也可以向这些重叠的订阅只发送一条消息。EMQX 属于前者。",{"type":48,"tag":148,"props":982,"children":984},{"id":983},"特性-9主题别名",[985],{"type":61,"value":986},"特性 9：主题别名",{"type":48,"tag":49,"props":988,"children":989},{},[990],{"type":61,"value":991},"MQTT 5.0 允许我们在发布消息时以一个两个字节长度的整数类型的主题别名来替代主题名，这在主题名较长时可以有效减少 PUBLISH 报文的大小。",{"type":48,"tag":49,"props":993,"children":994},{},[995],{"type":61,"value":996},"使用主题别名时，我们需要先发送一个同时包含主题名与主题别名的消息，让对端建立映射关系，然后才能发送仅包含主题别名的消息。",{"type":48,"tag":49,"props":998,"children":999},{},[1000],{"type":61,"value":1001},"主题别名的映射不属于会话状态的一部分，所以即便客户端重连时恢复了会话，它与服务端也需要重新建立主题别名的映射。",{"type":48,"tag":49,"props":1003,"children":1004},{},[1005],{"type":61,"value":1006},"客户端和服务端使用的主题别名映射相互独立。因此一般来说，客户端发送给服务端的主题别名值为 1 的消息和服务端发送给客户端的主题别名值为 1 的消息，将被映射到不同的主题。",{"type":48,"tag":49,"props":1008,"children":1009},{},[1010,1012,1017,1018,1024],{"type":61,"value":1011},"客户端和服务端还可以在连接时约定互相可以发送的主题别名的最大值。EMQX 默认允许的主题别名的最大值为 65535，我们可以打开 EMQX Dashboard（浏览器中输入 ",{"type":48,"tag":108,"props":1013,"children":1015},{"className":1014},[],[1016],{"type":61,"value":240},{"type":61,"value":242},{"type":48,"tag":108,"props":1019,"children":1021},{"className":1020},[],[1022],{"type":61,"value":1023},"Management -> MQTT Settings -> General",{"type":61,"value":1025}," 页面中的 Max Topic Alias 配置项来修改它。",{"type":48,"tag":49,"props":1027,"children":1028},{},[1029],{"type":48,"tag":260,"props":1030,"children":1033},{"alt":1031,"src":1032,"loading":264,"decoding":265},"MQTT 主题别名","https://assets.emqx.com/images/c853659e22cf620edc4eadb562cf7633.png?x-image-process=image/resize,w_1520/format,webp",[],{"type":48,"tag":148,"props":1035,"children":1037},{"id":1036},"特性-10流量控制",[1038],{"type":61,"value":1039},"特性 10：流量控制",{"type":48,"tag":49,"props":1041,"children":1042},{},[1043],{"type":61,"value":1044},"MQTT 5.0 中客户端与服务端可以在连接时使用接收最大值（Receive Maximum）来指示自己愿意同时处理的未确认的 QoS 1 和 QoS 2 消息的最大数量。",{"type":48,"tag":49,"props":1046,"children":1047},{},[1048],{"type":61,"value":1049},"当已经发送但未完全确认的消息数量达到接收最大值限制时，发送方就不能继续向接收方发送消息（QoS 0 消息不受此限制）。这可以有效避免发送方发送过快导致超出接收方的处理能力。",{"type":48,"tag":148,"props":1051,"children":1053},{"id":1052},"特性-11用户属性",[1054],{"type":61,"value":1055},"特性 11：用户属性",{"type":48,"tag":49,"props":1057,"children":1058},{},[1059],{"type":61,"value":1060},"MQTT 5.0 中的大部分报文都可以包含用户属性。用户属性是一个由 UTF-8 编码的字符串组成的名称-值对，名称和值的具体内容可以由客户端和服务端的实现自行定义，我们可以在没有超过报文最大长度的前提下指定任意多个用户属性。",{"type":48,"tag":49,"props":1062,"children":1063},{},[1064,1066,1073],{"type":61,"value":1065},"CONNECT、SUBSCRIBE 这类报文中的用户属性，通常取决于具体 ",{"type":48,"tag":53,"props":1067,"children":1070},{"href":1068,"rel":1069,"target":58},"https://www.emqx.com/zh/blog/the-ultimate-guide-to-mqtt-broker-comparison",[57,57],[1071],{"type":61,"value":1072},"MQTT 服务器",{"type":61,"value":1074},"的实现。",{"type":48,"tag":49,"props":1076,"children":1077},{},[1078],{"type":61,"value":1079},"PUBLISH 报文中的用户属性，会被服务端直接原封不动地转发给订阅端，所以只要消息的发布端和订阅端约定好用户属性的内容即可。比如在应用消息的用户属性中附上发布端的 Client ID，这样订阅端将可以知道消息来自哪里。",{"type":48,"tag":179,"props":1081,"children":1083},{"id":1082},"示例-8",[1084],{"type":61,"value":417},{"type":48,"tag":49,"props":1086,"children":1087},{},[1088],{"type":61,"value":1089},"订阅主题 t11：",{"type":48,"tag":103,"props":1091,"children":1093},{"code":1092},"mqttx sub --topic t11 --output-mode clean\n",[1094],{"type":48,"tag":108,"props":1095,"children":1096},{"__ignoreMap":41},[1097],{"type":61,"value":1092},{"type":48,"tag":49,"props":1099,"children":1100},{},[1101],{"type":61,"value":1102},"在另一个终端窗口中，向主题 t11 发布消息，并设置了两个用户属性，一个指示消息的来源，一个指示消息的发布时间：",{"type":48,"tag":103,"props":1104,"children":1106},{"code":1105},"mqttx pub --client-id pub11 --topic t11 --message \"Hello World\" --user-properties \"from: pub11\" --user-properties \"timestamp: 1691046633\"\n",[1107],{"type":48,"tag":108,"props":1108,"children":1109},{"__ignoreMap":41},[1110],{"type":61,"value":1105},{"type":48,"tag":49,"props":1112,"children":1113},{},[1114],{"type":61,"value":1115},"回到第一个终端窗口中，订阅端收到的消息中包含了我们设置的用户属性：",{"type":48,"tag":103,"props":1117,"children":1119},{"code":1118},"{\n  \"topic\": \"t11\",\n  \"payload\": \"Hello World\",\n  \"packet\": {\n        ...\n    \"properties\": {\n      \"userProperties\": {\n        \"from\": \"pub11\",\n        \"timestamp\": \"1691046633\"\n      }\n    }\n  }\n}\n",[1120],{"type":48,"tag":108,"props":1121,"children":1122},{"__ignoreMap":41},[1123],{"type":61,"value":1118},{"type":48,"tag":148,"props":1125,"children":1127},{"id":1126},"特性-12最大报文长度",[1128],{"type":61,"value":1129},"特性 12：最大报文长度",{"type":48,"tag":49,"props":1131,"children":1132},{},[1133],{"type":61,"value":1134},"MQTT 5.0 允许客户端和服务端在连接时通过 Maximum Packet Size 属性相互约定自己能够处理的最大报文长度，之后任何一方都不得发送超过约定长度限制的报文，否则将造成协议错误而被关闭连接。",{"type":48,"tag":49,"props":1136,"children":1137},{},[1138],{"type":61,"value":1139},"所以当 PUBLISH 报文过大导致无法转发时，服务端将直接丢弃该 PUBLISH 报文。",{"type":48,"tag":179,"props":1141,"children":1143},{"id":1142},"示例-1-2",[1144],{"type":61,"value":184},{"type":48,"tag":49,"props":1146,"children":1147},{},[1148],{"type":61,"value":1149},"在第一个终端窗口中，向服务端声明自己可接受的最大报文长度为 128 字节，并订阅主题 t12：",{"type":48,"tag":103,"props":1151,"children":1153},{"code":1152},"mqttx sub --maximum-packet-size 128 --topic t12\n…  Connecting...\n✔  Connected\n…  Subscribing to t12...\n✔  Subscribed to t12\n",[1154],{"type":48,"tag":108,"props":1155,"children":1156},{"__ignoreMap":41},[1157],{"type":61,"value":1152},{"type":48,"tag":49,"props":1159,"children":1160},{},[1161],{"type":61,"value":1162},"在第二个终端窗口中，发布一个长度小于 128 字节的消息：",{"type":48,"tag":103,"props":1164,"children":1166},{"code":1165},"payload=$(head -c 10 \u003C /dev/zero | tr '\\0' 0)\nmqttx pub --topic t12 -m \"$payload\"\n",[1167],{"type":48,"tag":108,"props":1168,"children":1169},{"__ignoreMap":41},[1170],{"type":61,"value":1165},{"type":48,"tag":49,"props":1172,"children":1173},{},[1174],{"type":61,"value":1175},"在第一个终端窗口中，订阅端将收到以下消息：",{"type":48,"tag":103,"props":1177,"children":1179},{"code":1178},"payload: 0000000000\n",[1180],{"type":48,"tag":108,"props":1181,"children":1182},{"__ignoreMap":41},[1183],{"type":61,"value":1178},{"type":48,"tag":49,"props":1185,"children":1186},{},[1187],{"type":61,"value":1188},"继续在第二个终端窗口中发布一个长度超过 128 字节的消息：",{"type":48,"tag":103,"props":1190,"children":1192},{"code":1191},"payload=$(head -c 128 \u003C /dev/zero | tr '\\0' 0)\nmqttx pub --topic t12 -m \"${payload}\"\n",[1193],{"type":48,"tag":108,"props":1194,"children":1195},{"__ignoreMap":41},[1196],{"type":61,"value":1191},{"type":48,"tag":49,"props":1198,"children":1199},{},[1200],{"type":61,"value":1201},"这一次第一个终端窗口中的订阅端将不会收到消息，我们输入 Ctrl+C 断开订阅端连接，然后运行以下命令查看 EMQX 日志：",{"type":48,"tag":103,"props":1203,"children":1205},{"code":1204},"docker logs emqx\n",[1206],{"type":48,"tag":108,"props":1207,"children":1208},{"__ignoreMap":41},[1209],{"type":61,"value":1204},{"type":48,"tag":49,"props":1211,"children":1212},{},[1213,1215,1221],{"type":61,"value":1214},"我们将看到消息因 ",{"type":48,"tag":108,"props":1216,"children":1218},{"className":1217},[],[1219],{"type":61,"value":1220},"frame_is_too_large",{"type":61,"value":1222}," 而被丢弃的日志：",{"type":48,"tag":103,"props":1224,"children":1226},{"code":1225},"2023-08-03T06:17:52.538541+00:00 [warning] msg: packet_is_discarded, mfa: emqx_connection:serialize_and_inc_stats_fun/1, line: 872, peername: 172.17.0.1:39164, clientid: mqttx_f0a3847c, packet: PUBLISH(Q0, R0, D0, Topic=t12, PacketId=undefined, Payload=******), reason: frame_is_too_large\n",[1227],{"type":48,"tag":108,"props":1228,"children":1229},{"__ignoreMap":41},[1230],{"type":61,"value":1225},{"type":48,"tag":179,"props":1232,"children":1234},{"id":1233},"示例-2-2",[1235],{"type":61,"value":229},{"type":48,"tag":49,"props":1237,"children":1238},{},[1239,1241,1246,1247,1252],{"type":61,"value":1240},"EMQX 默认允许的最大报文长度为 1MB，我们可以打开 EMQX Dashboard（浏览器中输入 ",{"type":48,"tag":108,"props":1242,"children":1244},{"className":1243},[],[1245],{"type":61,"value":240},{"type":61,"value":242},{"type":48,"tag":108,"props":1248,"children":1250},{"className":1249},[],[1251],{"type":61,"value":1023},{"type":61,"value":1253}," 页面中的 Max Packet Size 配置项来修改它。",{"type":48,"tag":49,"props":1255,"children":1256},{},[1257],{"type":61,"value":1258},"注意最大长度限制的是所有报文，所以如果设置了一个过小的最大报文长度，可能导致连接无法建立。这是我们要注意避免的。",{"type":48,"tag":49,"props":1260,"children":1261},{},[1262],{"type":61,"value":1263},"本示例中，我们将它修改为 1024 字节：",{"type":48,"tag":49,"props":1265,"children":1266},{},[1267],{"type":48,"tag":260,"props":1268,"children":1271},{"alt":1269,"src":1270,"loading":264,"decoding":265},"图片.png","https://assets.emqx.com/images/512963490e383148c2288bf5255f8751.png?x-image-process=image/resize,w_1520/format,webp",[],{"type":48,"tag":49,"props":1273,"children":1274},{},[1275],{"type":61,"value":1276},"然后在 Wireshark 中输入以下过滤语句抓取报文：",{"type":48,"tag":103,"props":1278,"children":1279},{"code":427},[1280],{"type":48,"tag":108,"props":1281,"children":1282},{"__ignoreMap":41},[1283],{"type":61,"value":427},{"type":48,"tag":49,"props":1285,"children":1286},{},[1287],{"type":61,"value":1288},"在终端窗口中，发布一个长度超过 1024 字节的消息：",{"type":48,"tag":103,"props":1290,"children":1292},{"code":1291},"payload=$(head -c 1024 \u003C /dev/zero | tr '\\0' 0)\nmqttx pub --client-id pub12 --topic t12 -m \"${payload}\"\n…  Connecting...\n✔  Connected\n…  Message publishing...\n✔  Message published\n",[1293],{"type":48,"tag":108,"props":1294,"children":1295},{"__ignoreMap":41},[1296],{"type":61,"value":1291},{"type":48,"tag":49,"props":1298,"children":1299},{},[1300],{"type":61,"value":1301},"在 Wireshark 中我们将看到 EMQX 返回了 DISCONNECT 报文，并将 Reason Code 被设置为 0x95，表示连接因为收到了过大的报文而被关闭：",{"type":48,"tag":49,"props":1303,"children":1304},{},[1305],{"type":48,"tag":260,"props":1306,"children":1308},{"alt":135,"src":1307,"loading":264,"decoding":265},"https://assets.emqx.com/images/3ac6a07014588cc82ea14365795e8843.png?x-image-process=image/resize,w_1520/format,webp",[],{"type":48,"tag":148,"props":1310,"children":1312},{"id":1311},"特性-13可选的服务端功能",[1313],{"type":61,"value":1314},"特性 13：可选的服务端功能",{"type":48,"tag":49,"props":1316,"children":1317},{},[1318],{"type":61,"value":1319},"MQTT 允许服务端不完全支持协议声明的功能和特性，但服务端需要在 CONNACK 报文中告知客户端自己不支持的功能，避免客户端使用这些不可用的功能。可选的服务端功能包括：",{"type":48,"tag":1321,"props":1322,"children":1323},"ul",{},[1324,1329,1334,1339,1344],{"type":48,"tag":97,"props":1325,"children":1326},{},[1327],{"type":61,"value":1328},"支持的最大 QoS 等级",{"type":48,"tag":97,"props":1330,"children":1331},{},[1332],{"type":61,"value":1333},"保留消息",{"type":48,"tag":97,"props":1335,"children":1336},{},[1337],{"type":61,"value":1338},"通配符订阅",{"type":48,"tag":97,"props":1340,"children":1341},{},[1342],{"type":61,"value":1343},"订阅标识符",{"type":48,"tag":97,"props":1345,"children":1346},{},[1347],{"type":61,"value":1348},"共享订阅",{"type":48,"tag":49,"props":1350,"children":1351},{},[1352],{"type":61,"value":1353},"如果客户端仍然使用了服务端已经告知不可用的功能，那么就会造成协议错误被服务端关闭连接。",{"type":48,"tag":179,"props":1355,"children":1357},{"id":1356},"示例-9",[1358],{"type":61,"value":417},{"type":48,"tag":49,"props":1360,"children":1361},{},[1362],{"type":61,"value":1363},"EMQX 默认支持所有 MQTT 特性，但我们可以手动关闭一些功能，比如通配符订阅、共享订阅以及保留消息等等。本示例中我们关闭了保留消息功能：",{"type":48,"tag":49,"props":1365,"children":1366},{},[1367],{"type":48,"tag":260,"props":1368,"children":1371},{"alt":1369,"src":1370,"loading":264,"decoding":265},"MQTT 关闭保留消息","https://assets.emqx.com/images/16873e4be8c387d5766c68b69d2a51f1.png?x-image-process=image/resize,w_1520/format,webp",[],{"type":48,"tag":49,"props":1373,"children":1374},{},[1375],{"type":61,"value":1276},{"type":48,"tag":103,"props":1377,"children":1378},{"code":427},[1379],{"type":48,"tag":108,"props":1380,"children":1381},{"__ignoreMap":41},[1382],{"type":61,"value":427},{"type":48,"tag":49,"props":1384,"children":1385},{},[1386],{"type":61,"value":1387},"在终端窗口中发布一条保留消息：",{"type":48,"tag":103,"props":1389,"children":1391},{"code":1390},"mqttx pub --topic t13 --message \"This is a retained message\" --retain\n…  Connecting...\n✔  Connected\n…  Message publishing...\n✔  Message published\n",[1392],{"type":48,"tag":108,"props":1393,"children":1394},{"__ignoreMap":41},[1395],{"type":61,"value":1390},{"type":48,"tag":49,"props":1397,"children":1398},{},[1399],{"type":61,"value":1400},"在 Wireshark 中我们将看到 EMQX 在 CONNACK 报文中返回了各个功能的可用情况，其中保留消息被声明为不可用：",{"type":48,"tag":49,"props":1402,"children":1403},{},[1404],{"type":48,"tag":260,"props":1405,"children":1407},{"alt":135,"src":1406,"loading":264,"decoding":265},"https://assets.emqx.com/images/542a90a629c938de745d7abb7016ca1e.png?x-image-process=image/resize,w_1520/format,webp",[],{"type":48,"tag":49,"props":1409,"children":1410},{},[1411],{"type":61,"value":1412},"而在客户端发布保留消息后，EMQX 返回了 DISCONNECT 报文，并将 Reason Code 被设置为 0x9A，表示服务端不支持保留消息：",{"type":48,"tag":49,"props":1414,"children":1415},{},[1416],{"type":48,"tag":260,"props":1417,"children":1419},{"alt":135,"src":1418,"loading":264,"decoding":265},"https://assets.emqx.com/images/e79cda1541771f559068a4813d1d3ded.png?x-image-process=image/resize,w_1520/format,webp",[],{"type":48,"tag":49,"props":1421,"children":1422},{},[1423],{"type":61,"value":1424},"完成此示例后，请将 EMQX 的保留消息功能再次打开，以免影响后续的示例。",{"type":48,"tag":148,"props":1426,"children":1428},{"id":1427},"特性-14订阅选项",[1429],{"type":61,"value":1430},"特性 14：订阅选项",{"type":48,"tag":49,"props":1432,"children":1433},{},[1434],{"type":61,"value":1435},"MQTT 5.0 在 QoS 的基础上又提供了三个新的订阅选项，分别为：",{"type":48,"tag":93,"props":1437,"children":1438},{},[1439,1444,1449],{"type":48,"tag":97,"props":1440,"children":1441},{},[1442],{"type":61,"value":1443},"No Local，用于指示消息是否可以被转发给发布此消息的客户端。",{"type":48,"tag":97,"props":1445,"children":1446},{},[1447],{"type":61,"value":1448},"Retain As Published，用于指示服务端向该订阅转发消息时是否需要保留其中的 Retain 标志。",{"type":48,"tag":97,"props":1450,"children":1451},{},[1452,1454],{"type":61,"value":1453},"Retain Handling，用于指示订阅建立时服务端是否需要向该订阅发送保留消息，这个选项有三个可取值：\n",{"type":48,"tag":93,"props":1455,"children":1456},{},[1457,1462,1467],{"type":48,"tag":97,"props":1458,"children":1459},{},[1460],{"type":61,"value":1461},"设置为 0，只要订阅建立，就发送保留消息。",{"type":48,"tag":97,"props":1463,"children":1464},{},[1465],{"type":61,"value":1466},"设置为 1，只有在订阅建立时该订阅当前不存在才发送保留消息。",{"type":48,"tag":97,"props":1468,"children":1469},{},[1470],{"type":61,"value":1471},"设置为 2，订阅建立时不发送保留消息。",{"type":48,"tag":49,"props":1473,"children":1474},{},[1475,1477,1484],{"type":61,"value":1476},"你可以阅读 ",{"type":48,"tag":53,"props":1478,"children":1481},{"href":1479,"rel":1480,"target":58},"https://www.emqx.com/zh/blog/an-introduction-to-subscription-options-in-mqtt",[57,57],[1482],{"type":61,"value":1483},"MQTT 订阅选项的使用",{"type":61,"value":1485}," 了解订阅选项的更多知识。",{"type":48,"tag":179,"props":1487,"children":1489},{"id":1488},"示例-1-no-local",[1490],{"type":61,"value":1491},"示例 1 - No Local",{"type":48,"tag":49,"props":1493,"children":1494},{},[1495,1497,1504],{"type":61,"value":1496},"客户端 sub14 和 pub14 分别发布一条消息到主题 t14，这里我们借助了 EMQX 的 ",{"type":48,"tag":53,"props":1498,"children":1501},{"href":1499,"rel":1500,"target":58},"https://docs.emqx.com/zh/emqx/v5.1/messaging/mqtt-delayed-publish.html#%E5%BB%B6%E8%BF%9F%E5%8F%91%E5%B8%83",[57,57],[1502],{"type":61,"value":1503},"延迟发布",{"type":61,"value":1505}," 功能，让消息延迟 10 秒发布：",{"type":48,"tag":103,"props":1507,"children":1509},{"code":1508},"mqttx pub --client-id sub14 --topic '$delayed/10/t14' --message \"You will not receive this message\"\nmqttx pub --client-id pub14 --topic '$delayed/10/t14' --message \"You will receive this message\"\n",[1510],{"type":48,"tag":108,"props":1511,"children":1512},{"__ignoreMap":41},[1513],{"type":61,"value":1508},{"type":48,"tag":49,"props":1515,"children":1516},{},[1517],{"type":61,"value":1518},"令客户端 sub14 订阅主题 t14，并设置 No Local 选项，它将收到客户端 pub14 发布的消息，但不会收到它自己发布的消息：",{"type":48,"tag":103,"props":1520,"children":1522},{"code":1521},"mqttx sub --client-id sub14 --topic t14 --no_local\n…  Connecting...\n✔  Connected\n…  Subscribing to t14...\n✔  Subscribed to t14\npayload: You will receive this message\n",[1523],{"type":48,"tag":108,"props":1524,"children":1525},{"__ignoreMap":41},[1526],{"type":61,"value":1521},{"type":48,"tag":179,"props":1528,"children":1530},{"id":1529},"示例-2-retain-as-published",[1531],{"type":61,"value":1532},"示例 2 - Retain As Published",{"type":48,"tag":49,"props":1534,"children":1535},{},[1536],{"type":61,"value":1537},"在第一个终端窗口中，订阅主题 t14，并设置 Retain As Published 选项：",{"type":48,"tag":103,"props":1539,"children":1541},{"code":1540},"mqttx sub --topic t14 --retain-as-published --output-mode clean\n",[1542],{"type":48,"tag":108,"props":1543,"children":1544},{"__ignoreMap":41},[1545],{"type":61,"value":1540},{"type":48,"tag":49,"props":1547,"children":1548},{},[1549],{"type":61,"value":1550},"在第二个终端窗口中，向主题 t14 发布一条保留消息：",{"type":48,"tag":103,"props":1552,"children":1554},{"code":1553},"mqttx pub --topic t14 --message \"Hello World\" --retain\n…  Connecting...\n✔  Connected\n…  Message publishing...\n✔  Message published\n",[1555],{"type":48,"tag":108,"props":1556,"children":1557},{"__ignoreMap":41},[1558],{"type":61,"value":1553},{"type":48,"tag":49,"props":1560,"children":1561},{},[1562],{"type":61,"value":1563},"在第一个终端窗口中，订阅端将收到设置了 Retain 标志位的消息：",{"type":48,"tag":103,"props":1565,"children":1567},{"code":1566},"{\n  \"topic\": \"t14\",\n  \"payload\": \"Hello World\",\n  \"packet\": {\n      ...\n    \"retain\": true,\n        ...\n  }\n}\n",[1568],{"type":48,"tag":108,"props":1569,"children":1570},{"__ignoreMap":41},[1571],{"type":61,"value":1566},{"type":48,"tag":49,"props":1573,"children":1574},{},[1575],{"type":61,"value":1576},"清除保留消息：",{"type":48,"tag":103,"props":1578,"children":1580},{"code":1579},"mqttx pub --topic t14 --message '' --retain\n",[1581],{"type":48,"tag":108,"props":1582,"children":1583},{"__ignoreMap":41},[1584],{"type":61,"value":1579},{"type":48,"tag":179,"props":1586,"children":1588},{"id":1587},"示例-3-retain-handling",[1589],{"type":61,"value":1590},"示例 3 - Retain Handling",{"type":48,"tag":49,"props":1592,"children":1593},{},[1594],{"type":61,"value":1595},"向主题 t14 发布一条保留消息：",{"type":48,"tag":103,"props":1597,"children":1599},{"code":1598},"mqttx pub --topic t14 --message \"This is a retained message\" --retain\n…  Connecting...\n✔  Connected\n…  Message publishing...\n✔  Message published\n",[1600],{"type":48,"tag":108,"props":1601,"children":1602},{"__ignoreMap":41},[1603],{"type":61,"value":1598},{"type":48,"tag":49,"props":1605,"children":1606},{},[1607],{"type":61,"value":1608},"订阅相同主题并设置 Retain Handling 为 0，我们将收到保留消息：",{"type":48,"tag":103,"props":1610,"children":1612},{"code":1611},"mqttx sub --client-id sub14 --session-expiry-interval 300 --topic t14 --retain-handling 0\n…  Connecting...\n✔  Connected\n…  Subscribing to t14...\n✔  Subscribed to t14\npayload: This is a retained message\nretain: true\n^C\n",[1613],{"type":48,"tag":108,"props":1614,"children":1615},{"__ignoreMap":41},[1616],{"type":61,"value":1611},{"type":48,"tag":49,"props":1618,"children":1619},{},[1620],{"type":61,"value":1621},"在终端输入 Ctrl+C 断开客户端连接。",{"type":48,"tag":49,"props":1623,"children":1624},{},[1625],{"type":61,"value":1626},"重连并恢复会话，订阅相同主题，但是将 Retain Handling 设置为 1，这一次我们将不会收到保留消息，因为在服务端此订阅已经存在：",{"type":48,"tag":103,"props":1628,"children":1630},{"code":1629},"mqttx sub --client-id sub14 --no-clean --session-expiry-interval 300 --topic t14 --retain-handling 1\n…  Connecting...\n✔  Connected\n…  Subscribing to t14...\n✔  Subscribed to t14\n^C\n",[1631],{"type":48,"tag":108,"props":1632,"children":1633},{"__ignoreMap":41},[1634],{"type":61,"value":1629},{"type":48,"tag":49,"props":1636,"children":1637},{},[1638],{"type":61,"value":1621},{"type":48,"tag":49,"props":1640,"children":1641},{},[1642],{"type":61,"value":1643},"重连但创建一个全新的会话，订阅相同主题，将 Retain Handling 设置为 2，这一次我们仍然不会收到保留消息：",{"type":48,"tag":103,"props":1645,"children":1647},{"code":1646},"mqttx sub --client-id sub14 --topic t14 --retain-handling 2\n…  Connecting...\n✔  Connected\n…  Subscribing to t14...\n✔  Subscribed to t14\n",[1648],{"type":48,"tag":108,"props":1649,"children":1650},{"__ignoreMap":41},[1651],{"type":61,"value":1646},{"type":48,"tag":49,"props":1653,"children":1654},{},[1655],{"type":61,"value":1576},{"type":48,"tag":103,"props":1657,"children":1658},{"code":1579},[1659],{"type":48,"tag":108,"props":1660,"children":1661},{"__ignoreMap":41},[1662],{"type":61,"value":1579},{"type":48,"tag":148,"props":1664,"children":1666},{"id":1665},"特性-15遗嘱延迟",[1667],{"type":61,"value":1668},"特性 15：遗嘱延迟",{"type":48,"tag":49,"props":1670,"children":1671},{},[1672],{"type":61,"value":1673},"在 MQTT 5.0 中，客户端可以为遗嘱消息设置一个延迟间隔，而不再是让它在网络连接断开时就立即发布，如果客户端连接能够遗嘱延迟间隔到达前及时恢复，那么遗嘱消息就不会被发布。这可以有效地避免遗嘱消息仅仅因为客户端连接的短暂中断而被发布。",{"type":48,"tag":49,"props":1675,"children":1676},{},[1677],{"type":61,"value":1678},"如果遗嘱延迟间隔大于会话过期间隔，那么遗嘱消息将在会话过期时被立即发送，所以我们还可以将遗嘱消息用于会话到期通知。",{"type":48,"tag":179,"props":1680,"children":1682},{"id":1681},"示例-1-3",[1683],{"type":61,"value":184},{"type":48,"tag":49,"props":1685,"children":1686},{},[1687],{"type":61,"value":1688},"在第一个终端窗口中订阅主题 t15：",{"type":48,"tag":103,"props":1690,"children":1692},{"code":1691},"mqttx sub --topic t15\n…  Connecting...\n✔  Connected\n…  Subscribing to t15...\n✔  Subscribed to t15\n",[1693],{"type":48,"tag":108,"props":1694,"children":1695},{"__ignoreMap":41},[1696],{"type":61,"value":1691},{"type":48,"tag":49,"props":1698,"children":1699},{},[1700],{"type":61,"value":1701},"在第二个终端窗口中建立一个设置了遗嘱消息的 MQTT 连接，并将遗嘱延迟间隔设置为 10 秒。连接成功后输入 Ctrl+C 断开客户端连接：",{"type":48,"tag":103,"props":1703,"children":1705},{"code":1704},"mqttx conn --client-id conn15 --will-topic t15 --will-message \"I'm offline\" --will-delay-interval 10 --session-expiry-interval 300\n…  Connecting...\n✔  Connected\n^C\n",[1706],{"type":48,"tag":108,"props":1707,"children":1708},{"__ignoreMap":41},[1709],{"type":61,"value":1704},{"type":48,"tag":49,"props":1711,"children":1712},{},[1713],{"type":61,"value":1714},"第一个终端窗口中的订阅端将在 10 秒后收到遗嘱消息：",{"type":48,"tag":103,"props":1716,"children":1718},{"code":1717},"payload: I'm offline\n",[1719],{"type":48,"tag":108,"props":1720,"children":1721},{"__ignoreMap":41},[1722],{"type":61,"value":1717},{"type":48,"tag":179,"props":1724,"children":1726},{"id":1725},"示例-2-3",[1727],{"type":61,"value":229},{"type":48,"tag":49,"props":1729,"children":1730},{},[1731],{"type":61,"value":1732},"在第二个终端窗口中再次建立一个设置了遗嘱消息的 MQTT 连接，并将遗嘱延迟间隔设置为 10 秒。连接成功后输入 Ctrl+C 断开客户端连接：",{"type":48,"tag":103,"props":1734,"children":1735},{"code":1704},[1736],{"type":48,"tag":108,"props":1737,"children":1738},{"__ignoreMap":41},[1739],{"type":61,"value":1704},{"type":48,"tag":49,"props":1741,"children":1742},{},[1743],{"type":61,"value":1744},"在 10 秒内重连：",{"type":48,"tag":103,"props":1746,"children":1748},{"code":1747},"mqttx conn --client-id conn15 --will-topic t15 --will-message \"I'm offline\" --will-delay-interval 10 --no-clean --session-expiry-interval 300\n",[1749],{"type":48,"tag":108,"props":1750,"children":1751},{"__ignoreMap":41},[1752],{"type":61,"value":1747},{"type":48,"tag":49,"props":1754,"children":1755},{},[1756],{"type":61,"value":1757},"这一次第一个终端窗口中的订阅端将不会收到遗嘱消息。",{"type":48,"tag":179,"props":1759,"children":1761},{"id":1760},"示例-3-1",[1762],{"type":61,"value":1763},"示例 3",{"type":48,"tag":49,"props":1765,"children":1766},{},[1767],{"type":61,"value":1768},"我们还可以为遗嘱消息设置 Will Retain 标识，让它成为一个保留消息，避免订阅端因不在线而错过遗嘱消息。",{"type":48,"tag":49,"props":1770,"children":1771},{},[1772],{"type":61,"value":1773},"继续在第二个终端窗口中建立一个设置了遗嘱消息的 MQTT 连接，这一次我们将遗嘱延迟间隔设置为 0 秒，因此遗嘱消息将在连接断开时立即发布。连接成功后输入 Ctrl+C 断开客户端连接：",{"type":48,"tag":103,"props":1775,"children":1777},{"code":1776},"mqttx conn --client-id conn15 --will-topic t15 --will-message \"I'm offline\" --will-delay-interval 0 --will-retain --session-expiry-interval 300\n…  Connecting...\n✔  Connected\n^C\n",[1778],{"type":48,"tag":108,"props":1779,"children":1780},{"__ignoreMap":41},[1781],{"type":61,"value":1776},{"type":48,"tag":49,"props":1783,"children":1784},{},[1785],{"type":61,"value":1786},"在第一个终端窗口中订阅主题 t15，我们将收到在这之前发布的遗嘱消息：",{"type":48,"tag":103,"props":1788,"children":1790},{"code":1789},"mqttx sub --topic t15\n…  Connecting...\n✔  Connected\n…  Subscribing to t15...\n✔  Subscribed to t15\npayload: I'm offline\nretain: true\n",[1791],{"type":48,"tag":108,"props":1792,"children":1793},{"__ignoreMap":41},[1794],{"type":61,"value":1789},{"type":48,"tag":148,"props":1796,"children":1798},{"id":1797},"特性-16由服务端指定保活时间",[1799],{"type":61,"value":1800},"特性 16：由服务端指定保活时间",{"type":48,"tag":49,"props":1802,"children":1803},{},[1804],{"type":61,"value":1805},"保活时间决定了客户端发送相邻两个控制报文的最大空闲时间，服务端可以根据是否在预期的时间内收到客户端的报文来判断它是否仍然活跃。",{"type":48,"tag":49,"props":1807,"children":1808},{},[1809],{"type":61,"value":1810},"在 MQTT 5.0 中，服务端可以不接受客户端指定的保活时间，并在 CONNACK 报文中返回它希望客户端使用的 Keep Alive，客户端必须使用这个保活时间来维持通信。",{"type":48,"tag":179,"props":1812,"children":1814},{"id":1813},"示例-10",[1815],{"type":61,"value":417},{"type":48,"tag":49,"props":1817,"children":1818},{},[1819,1821,1826,1827,1832],{"type":61,"value":1820},"EMQX 默认由客户端指定保活时间，我们可以打开 EMQX Dashboard（浏览器中输入 ",{"type":48,"tag":108,"props":1822,"children":1824},{"className":1823},[],[1825],{"type":61,"value":240},{"type":61,"value":242},{"type":48,"tag":108,"props":1828,"children":1830},{"className":1829},[],[1831],{"type":61,"value":1023},{"type":61,"value":1833}," 页面中的 Server Keep Alive 配置项来修改它。",{"type":48,"tag":49,"props":1835,"children":1836},{},[1837],{"type":61,"value":1838},"本示例中，我们将它修改为 10 秒：",{"type":48,"tag":49,"props":1840,"children":1841},{},[1842],{"type":48,"tag":260,"props":1843,"children":1846},{"alt":1844,"src":1845,"loading":264,"decoding":265},"MQTT 保活时间","https://assets.emqx.com/images/db10dece7733daaa0bde63bdda8e314e.png?x-image-process=image/resize,w_1520/format,webp",[],{"type":48,"tag":49,"props":1848,"children":1849},{},[1850],{"type":61,"value":1276},{"type":48,"tag":103,"props":1852,"children":1853},{"code":427},[1854],{"type":48,"tag":108,"props":1855,"children":1856},{"__ignoreMap":41},[1857],{"type":61,"value":427},{"type":48,"tag":49,"props":1859,"children":1860},{},[1861],{"type":61,"value":1862},"回到终端窗口，发起一个 MQTT 连接，并将 Keep Alive 设置为 30 秒：",{"type":48,"tag":103,"props":1864,"children":1866},{"code":1865},"mqttx conn --keepalive 30\n…  Connecting...\n✔  Connected\n",[1867],{"type":48,"tag":108,"props":1868,"children":1869},{"__ignoreMap":41},[1870],{"type":61,"value":1865},{"type":48,"tag":49,"props":1872,"children":1873},{},[1874],{"type":61,"value":1875},"我们将在 Wireshark 中看到 EMQX 在返回的 CONNACK 报文中设置了 Server Keep Alive 属性，且值为 10。连接建立后，客户端也是以 10 秒为间隔发送心跳报文而不是 30 秒：",{"type":48,"tag":49,"props":1877,"children":1878},{},[1879],{"type":48,"tag":260,"props":1880,"children":1882},{"alt":135,"src":1881,"loading":264,"decoding":265},"https://assets.emqx.com/images/2285d82210f5ba969519114020937ef1.png?x-image-process=image/resize,w_1520/format,webp",[],{"type":48,"tag":148,"props":1884,"children":1886},{"id":1885},"特性-17-返回服务端分配的-client-id",[1887],{"type":61,"value":1888},"特性 17: 返回服务端分配的 Client ID",{"type":48,"tag":49,"props":1890,"children":1891},{},[1892],{"type":61,"value":1893},"当客户端使用一个长度为 0 的 Client ID 发起连接时，服务端将会为客户端分配一个唯一的 Client ID。在 MQTT 5.0 中，这个分配的 Client ID 可以包含在 CONNACK 报文中返回给客户端。这避免了客户端因为不知道 Client ID 而无法在下一次连接时恢复会话。",{"type":48,"tag":179,"props":1895,"children":1897},{"id":1896},"示例-11",[1898],{"type":61,"value":417},{"type":48,"tag":49,"props":1900,"children":1901},{},[1902],{"type":61,"value":478},{"type":48,"tag":103,"props":1904,"children":1905},{"code":427},[1906],{"type":48,"tag":108,"props":1907,"children":1908},{"__ignoreMap":41},[1909],{"type":61,"value":427},{"type":48,"tag":49,"props":1911,"children":1912},{},[1913],{"type":61,"value":1914},"回到终端窗口，发起一个 MQTT 连接，并将 Client ID 设置为一个长度为 0 的字符串：",{"type":48,"tag":103,"props":1916,"children":1918},{"code":1917},"mqttx conn --client-id ''\n",[1919],{"type":48,"tag":108,"props":1920,"children":1921},{"__ignoreMap":41},[1922],{"type":61,"value":1917},{"type":48,"tag":49,"props":1924,"children":1925},{},[1926],{"type":61,"value":1927},"我们将在 Wireshark 中看到 EMQX 返回的 CONNACK 报文中包含了一个 Assigned Client Identifier 属性，它的值就是 EMQX 为客户端分配的 Client ID：",{"type":48,"tag":49,"props":1929,"children":1930},{},[1931],{"type":48,"tag":260,"props":1932,"children":1934},{"alt":135,"src":1933,"loading":264,"decoding":265},"https://assets.emqx.com/images/ed6e0702da12fdf44e13504af7162759.png?x-image-process=image/resize,w_1520/format,webp",[],{"type":48,"tag":148,"props":1936,"children":1938},{"id":1937},"结语",[1939],{"type":61,"value":1937},{"type":48,"tag":49,"props":1941,"children":1942},{},[1943,1945,1952],{"type":61,"value":1944},"以上就是 MQTT 5.0 所有特性的基本介绍与演示，你可以试着将演示中的步骤转换成代码然后在你的客户端中复现。如果你希望了解这些 MQTT 5.0 全新特性的更多内容，你可以访问我们的 ",{"type":48,"tag":53,"props":1946,"children":1949},{"href":1947,"rel":1948,"target":58},"https://www.emqx.com/en/mqtt-guide",[57,57],[1950],{"type":61,"value":1951},"MQTT Guide",{"type":61,"value":1953},"，它聚合了所有你需要知道的 MQTT 的知识。",{"title":41,"searchDepth":1955,"depth":1955,"links":1956},2,[1957,1962,1966,1969,1972,1975,1978,1981,1984,1985,1986,1989,1993,1996,2001,2006,2009,2012],{"id":150,"depth":1955,"text":153,"children":1958},[1959,1961],{"id":181,"depth":1960,"text":184},3,{"id":226,"depth":1960,"text":229},{"id":282,"depth":1955,"text":285,"children":1963},[1964,1965],{"id":308,"depth":1960,"text":184},{"id":352,"depth":1960,"text":229},{"id":383,"depth":1955,"text":386,"children":1967},[1968],{"id":417,"depth":1960,"text":417},{"id":460,"depth":1955,"text":463,"children":1970},[1971],{"id":471,"depth":1960,"text":417},{"id":539,"depth":1955,"text":542,"children":1973},[1974],{"id":563,"depth":1960,"text":417},{"id":614,"depth":1955,"text":617,"children":1976},[1977],{"id":635,"depth":1960,"text":417},{"id":726,"depth":1955,"text":729,"children":1979},[1980],{"id":750,"depth":1960,"text":417},{"id":884,"depth":1955,"text":887,"children":1982},[1983],{"id":895,"depth":1960,"text":417},{"id":983,"depth":1955,"text":986},{"id":1036,"depth":1955,"text":1039},{"id":1052,"depth":1955,"text":1055,"children":1987},[1988],{"id":1082,"depth":1960,"text":417},{"id":1126,"depth":1955,"text":1129,"children":1990},[1991,1992],{"id":1142,"depth":1960,"text":184},{"id":1233,"depth":1960,"text":229},{"id":1311,"depth":1955,"text":1314,"children":1994},[1995],{"id":1356,"depth":1960,"text":417},{"id":1427,"depth":1955,"text":1430,"children":1997},[1998,1999,2000],{"id":1488,"depth":1960,"text":1491},{"id":1529,"depth":1960,"text":1532},{"id":1587,"depth":1960,"text":1590},{"id":1665,"depth":1955,"text":1668,"children":2002},[2003,2004,2005],{"id":1681,"depth":1960,"text":184},{"id":1725,"depth":1960,"text":229},{"id":1760,"depth":1960,"text":1763},{"id":1797,"depth":1955,"text":1800,"children":2007},[2008],{"id":1813,"depth":1960,"text":417},{"id":1885,"depth":1955,"text":1888,"children":2010},[2011],{"id":1896,"depth":1960,"text":417},{"id":1937,"depth":1955,"text":1937},"markdown","content:blog:zh:demonstrate-mqtt-5-0-features-using-mqttx-cli.md","content","blog/zh/demonstrate-mqtt-5-0-features-using-mqttx-cli.md","md",{"loc":2019,"lastmod":30},"/zh/blog/demonstrate-mqtt-5-0-features-using-mqttx-cli",[2021,2029,2036,2042,2049,2056,2063,2069,2076,2083,2090,2097,2104,2110,2117,2124,2131,2138,2145,2146,2153,2160,2167,2174,2181,2188,2194,2201,2208,2215,2221,2228,2235],{"slug":2022,"title":2023,"description":2024,"date":2025,"category":2026,"cover":2027,"version":2028},"mqttx-1-13-2-released","MQTTX 1.13.2 发布：MQTTX Agent 与 Dashboard","MQTTX 1.13.2 通过 MQTTX Agent 自动执行 MQTT 测试、比对消息并排查问题，Dashboard 独立展示设备指标与趋势。","2026-10-26","release-notes","/images/blog/mqttx-1-13-2-released.webp","1.13.2",{"slug":2030,"title":2031,"description":2032,"date":2033,"category":2034,"cover":2035,"version":-1},"introducing-mqttx-ai-agent-skill","MQTTX AI Agent Skill 正式发布","MQTTX CLI 内置的 Agent Skill，让 AI 编码 Agent 能够正确、安全地完成 MQTT 连接检查、消息收发、压测与数据模拟。","2026-09-20","product","/images/blog/introducing-mqttx-ai-agent-skill.webp",{"slug":2037,"title":2038,"description":2039,"date":2033,"category":2026,"cover":2040,"version":2041},"mqttx-1-13-1-released","MQTTX 1.13.1 发布：AI Agent Skill 与 MQTT 5.0 订阅用户属性","MQTTX 1.13.1 新增 CLI Agent Skill 和 MQTT 5.0 订阅用户属性，同时改进数据导出、渲染安全与日常调试体验。","/images/blog/mqttx-1-13-1-released.webp","1.13.1",{"slug":2043,"title":2044,"description":2045,"date":2046,"category":2026,"cover":2047,"version":2048},"mqttx-1-13-0-released","MQTTX 1.13.0 发布：消息体查看器与 UI 优化","该版本带来了全新的消息体查看器功能，包含差异视图和 JSON 树视图，让消息调试更加直观高效。同时新增快速复制功能，支持一键复制 Topic、Payload 和连接地址。","2026-02-03","https://assets.emqx.com/images/8c7121a4362a9bfa897396a3fc8fefaa.png","1.13.0",{"slug":2050,"title":2051,"description":2052,"date":2053,"category":2026,"cover":2054,"version":2055},"mqttx-1-12-1-release-notes","MQTTX 1.12.1 发布：SCRAM 认证与安全增强","MQTTX 1.12.1 带来了重要的安全更新，包括全平台支持的 SCRAM 增强认证、修复了消息显示中的 XSS 漏洞、更新了 2025 年最新的 AI 模型，以及关键的稳定性改进。","2025-10-16","https://assets.emqx.com/images/8e89d5d55c44425251ab2b7e84fdb5c8.png","1.12.1",{"slug":2057,"title":2058,"description":2059,"date":2060,"category":2026,"cover":2061,"version":2062},"mqttx-1-12-0-release-notes","MQTTX 1.12.0 发布：Copilot 2.0 & 原生 MCP 集成","MQTTX 1.12.0 版本正式发布，带来了 Copilot 2.0 功能（集成 Gemini 2.5 Pro、Claude-4、GPT-4.1、o3/o4-mini、Azure OpenAI 等模型）。","2025-07-03","https://assets.emqx.com/images/2ff9750580cb332de42e887eef90dfb4.jpg","1.12.0",{"slug":2064,"title":2065,"description":2066,"date":2067,"category":2034,"cover":2068,"version":-1},"enhancing-mqtt-toolbox-with-ai-capabilities","MQTTX + MCP：MQTT 客户端秒变物联网 Agent","作为最受欢迎的 MQTT 客户端工具，MQTTX 在 1.12.0 beta 版本中集成了模型上下文协议（MCP）到 Copilot AI 功能中，显著提升了服务能力。","2025-04-17","https://assets.emqx.com/images/0414033f16fee53f3c8b8e3538a38fef.png",{"slug":2070,"title":2071,"description":2072,"date":2073,"category":2026,"cover":2074,"version":2075},"mqttx-1-11-1-release-notes","MQTTX 1.11.1 发布: 可视化功能增强","该版本增强了 MQTTX 的可视化功能，改进了主题树功能和实时流量监控。新增的流量速率监控功能为用户提供实时数据包追踪，主题树现在支持与连接列表的手动同步以及 MQTT 属性显示。","2024-12-20","https://assets.emqx.com/images/2f182bc8a29fb11bf11a6f39a67bec7c.jpg","1.11.1",{"slug":2077,"title":2078,"description":2079,"date":2080,"category":2026,"cover":2081,"version":2082},"mqttx-1-11-0-release-notes","MQTTX 1.11.0 发布：Topic Tree 与 Avro Schema","本次发布引入了 Topic Tree 可视化功能，提供了一种按层级组织和监控 MQTT 主题的强大新方式。","2024-10-29","https://assets.emqx.com/images/dba4e395e4043265d635384c6670c206.jpg","1.11.0",{"slug":2084,"title":2085,"description":2086,"date":2087,"category":2026,"cover":2088,"version":2089},"mqttx-1-10-1-release-notes","MQTTX 1.10.1 发布：桌面端一键安装命令行工具","本次更新带来了一系列提升用户体验的重要功能：通过桌面应用一键安装 MQTTX 命令行工具；增加对自定义 AI Copilot API 的支持，为中国区域内的用户提供内置的 Moonshot LLM API。","2024-07-25","https://assets.emqx.com/images/c83ea38e592729c4349f39fa8ee2883a.jpg","1.10.1",{"slug":2091,"title":2092,"description":2093,"date":2094,"category":2026,"cover":2095,"version":2096},"mqttx-1-10-0-release-notes","MQTTX 1.10.0 发布：CLI高级文件管理与配置","在本次更新中，CLI 版本在文件管理和配置功能方面进行了显著增强。主要更新包括：支持从文件中读取和写入消息、高级配置选项、文本输出模式、以及改进的日志记录。","2024-06-14","https://assets.emqx.com/images/76adac845cbb113915947ca5b76631a5.jpg","1.10.0",{"slug":2098,"title":2099,"description":2100,"date":2101,"category":2026,"cover":2102,"version":2103},"mqttx-1-9-10-release-notes","MQTTX 1.9.10 发布：升级 Faker.js、增强连接与订阅诊断、优化 UI","MQTTX 1.9.10 引入了一项关键更新：将 Faker.js 升级到 v8，带来重大变更。此次升级将影响那些使用自定义模拟脚本的用户，需要对脚本进行修改以保持与新版本的兼容。","2024-04-25","https://assets.emqx.com/images/f4a343ea4a9accc7c2b9047e2ee992aa.png","1.9.10",{"slug":2105,"title":2106,"description":2107,"date":2108,"category":31,"cover":2109,"version":-1},"how-to-publish-and-receive-protobuf-messages-within-mqtt","如何在 MQTT 中发布和接收 Protobuf 消息？","MQTTX 是一款开源的全功能 MQTT 客户端，支持从 JSON、Base64 到现如今的 Protobuf 的多种格式。我们将在本文中展示如何使用 MQTTX 来定义、发布和接收 Protobuf 消息。","2024-04-17","https://assets.emqx.com/images/348e290abdede74446c634642b1bfcf7.png",{"slug":2111,"title":2112,"description":2113,"date":2114,"category":2026,"cover":2115,"version":2116},"mqttx-1-9-9-release-notes","MQTTX 1.9.9 发布：新增日志级别自定义功能、UI 增强","MQTTX 1.9.9 现已正式发布。该版本带来了多项关键更新：包括优化连接事件的处理、新增 CBOR 数据格式支持、提供可定制的调试日志级别以及增强用户界面灵活性。","2024-02-21","https://assets.emqx.com/images/2f5c68eb83929b730860399f9486ae21.png","1.9.9",{"slug":2118,"title":2119,"description":2120,"date":2121,"category":2026,"cover":2122,"version":2123},"mqttx-1-9-8-release-notes","MQTTX 1.9.8 发布：CLI 支持调试模式、AI Copilot 增强","MQTTX 1.9.8 现已发布，新版本中 MQTTX CLI 新增了调试模式，这一功能增强了开发者的故障排查和分析能力。此外，更新也改进了 MQTTX AI Copilot 功能，为用户提供了更先进的基于 AI 驱动的 MQTT 交互支持。","2024-01-29","https://assets.emqx.com/images/5624cf41d474bf0cf8b6aaa47cf09c1f.png","1.9.8",{"slug":2125,"title":2126,"description":2127,"date":2128,"category":2026,"cover":2129,"version":2130},"mqttx-1-9-7-release-notes","MQTTX 1.9.7 更新：MQTTX AI Copilot 发布","此次更新的一大亮点是引入了 MQTTX Copilot，全新的 MQTT AI 助手，为用户提供更方便、快捷的使用体验。AI 助手能增强用户互动，帮助用户更深入理解并使用 MQTT 和 EMQX。","2024-01-22","https://assets.emqx.com/images/18f1a0ab5e4967d46c2b9d351da052a4.png","1.9.7",{"slug":2132,"title":2133,"description":2134,"date":2135,"category":2026,"cover":2136,"version":2137},"mqttx-v-1-9-6-release-notes","MQTTX 1.9.6 发布：ALPN 协议支持，UI 持续优化","本次更新主要重点在于加强连接协议、并对用户界面进行了优化，旨在提供一个更高效、安全和用户友好的体验。","2023-09-26","https://assets.emqx.com/images/359278439c384548665bfb0388f0aa24.png","1.9.6",{"slug":2139,"title":2140,"description":2141,"date":2142,"category":2026,"cover":2143,"version":2144},"mqttx-1-9-5-released-json-message-highlighting-and-more","MQTTX 1.9.5 发布：JSON 消息高亮显示","MQTT 5.0 客户端工具 MQTTX 1.9.5 正式发布。本次更新中，我们主要针对桌面客户端强化了 JSON 语法的错误消息提示，并在消息中增加了 JSON 高亮的支持。此外，我们还对 UI 进行了多项修改和优化，以进一步增强用户体验。","2023-08-25","https://assets.emqx.com/images/f82115ce699de70fb54e8f45adacf878.png","1.9.5",{"slug":27,"title":28,"description":29,"date":30,"category":31,"cover":32,"version":-1},{"slug":2147,"title":2148,"description":2149,"date":2150,"category":2026,"cover":2151,"version":2152},"mqttx-v-1-9-4-release-notes","MQTTX 1.9.4 发布：全面支持 Protobuf 格式 MQTT 消息传输测试","MQTTX 1.9.4 正式发布：本次更新为用户提供了更高效的 Protobuf 消息传输支持，并优化了自动更新功能，同时进行了一些功能特性的优化和增强。","2023-08-01","https://assets.emqx.com/images/cde7c8e2e51e7398057cb8e11d811192.png","1.9.4",{"slug":2154,"title":2155,"description":2156,"date":2157,"category":2026,"cover":2158,"version":2159},"mqttx-1-9-3-introduces-powerful-iot-scenario-data-simulation-feature","提升开发效率：MQTTX 1.9.3 推出强大的 IoT 场景数据模拟功能","MQTTX 1.9.3 为命令行客户端带来了一项重要增强：开发者可以模拟 IoT 场景数据，满足特定的测试需求。","2023-05-29","https://assets.emqx.com/images/657ba5a04f29a7b318206a642223db8f.png","1.9.3",{"slug":2161,"title":2162,"description":2163,"date":2164,"category":2026,"cover":2165,"version":2166},"mqttx-v-1-9-2-release-notes","MQTTX 1.9.2 发布：更出色的 MQTT 客户端工具箱","v1.9.2 支持命令行工具的输出模式，用户可以根据需要自定义数据管道，从而更便捷、高效地处理输出数据。","2023-04-27","https://assets.emqx.com/images/44cad865821d28706395fd74e8bd766a.png","1.9.2",{"slug":2168,"title":2169,"description":2170,"date":2171,"category":2026,"cover":2172,"version":2173},"mqttx-v-1-9-1-release-notes","MQTTX 1.9.1 发布：资源消耗降低 80%，稳定性大幅提升","MQTT 5.0 客户端工具 MQTT X 1.9.1 稳定版本正式发布，CPU 资源消耗与内存占用减少 80%，整体性能得到大幅优化。","2023-02-10","https://assets.emqx.com/images/c7f10755128e074ae4e28cd8139b790f.png","1.9.1",{"slug":2175,"title":2176,"description":2177,"date":2178,"category":2026,"cover":2179,"version":2180},"mqttx-v-1-9-0-release-notes","MQTTX 1.9.0 发布：开箱即用的 bench 命令，MQTT 性能测试更便捷","近日，MQTT 5.0 客户端工具 MQTT X 1.9.0 正式发布：命令行客户端新增了 bench 命令，帮助用户轻松完成 MQTT 服务的性能测试。","2022-11-15","https://assets.emqx.com/images/c5a4b83637473e6e414b11101046771f.png","1.9.0",{"slug":2182,"title":2183,"description":2184,"date":2185,"category":2026,"cover":2186,"version":2187},"mqttx-v-1-8-3-release-notes","MQTTX v1.8.3 正式发布","MQTT X v1.8.3 优化了 MQTT 5.0 Clean Start 的使用方式，为会话过期间隔添加默认值；同时也改进了 MQTT X CLI 的默认输出显示。","2022-10-20","https://assets.emqx.com/images/a9fd38699c5731bd4210c81297ac8af4.png","1.8.3",{"slug":2189,"title":2190,"description":2191,"date":2192,"category":2034,"cover":2193,"version":-1},"powerful-and-easy-to-use-mqtt-5-command-line-tool","MQTTX CLI 发布：强大易用的 MQTT 5.0 命令行工具","MQTT X v1.8.0 发布：除了通过新增的快速复制连接功能优化使用体验之外，还增加了 CLI（命令行） 和 Web 端这两种新的交互方式 。","2022-07-21","https://assets.emqx.com/images/2780d4b1fe9f0f3c0792515feb90b1e1.png",{"slug":2195,"title":2196,"description":2197,"date":2198,"category":2026,"cover":2199,"version":2200},"mqttx-v-1-7-2-release-notes","MQTTX v1.7.2 正式发布","MQTT X v1.7.1 正式发布：支持设置重连周期，增加更多的 ARM 包，共享订阅支持 Topic 颜色标记。","2022-01-28","https://assets.emqx.com/images/241fe4ef50adbfdea9e43979028757b2.png","1.7.2",{"slug":2202,"title":2203,"description":2204,"date":2205,"category":2026,"cover":2206,"version":2207},"mqttx-v-1-7-1-release-notes","MQTTX v1.7.1 正式发布","MQTT X v1.7.1 正式发布，新增支持 MQTT 5.0 订阅标识符、 编辑/启用/禁用 Topic、并优化了 MQTT 5.0 的属性展示。","2022-01-18","https://assets.emqx.com/images/a2df1acb1d15e7e9378ec9e1ebcdc716.png","1.7.1",{"slug":2209,"title":2210,"description":2211,"date":2212,"category":2026,"cover":2213,"version":2214},"mqttx-v-1-7-0-release-notes","MQTTX v1.7.0 发布：率先支持 MQTT 5.0 新特性的桌面测试客户端","MQTT X v1.7.0 新增很多关于 MQTT 5.0 的属性配置功能支持，使其成为目前同类工具中支持 MQTT 5.0 最为完整的 MQTT 桌面客户端工具。","2021-12-16","https://assets.emqx.com/images/6ed96b88a4524e11609b2e4fd792574c.png","1.7.0",{"slug":2216,"title":2217,"description":2218,"date":2219,"category":31,"cover":2220,"version":-1},"mqttx-script-function-tutorial","MQTTX 脚本功能使用教程","MQTT X 在 v1.4.2 版本后加入了脚本功能，用户可使用脚本对 Payload 进行自定义转换，本文将通过两个简单的实例来介绍脚本功能的使用。","2021-02-23","https://assets.emqx.com/images/d9b2744f485887c9fae26133ed2e4b14.png",{"slug":2222,"title":2223,"description":2224,"date":2225,"category":2026,"cover":2226,"version":2227},"mqttx-v-1-4-2-release-notes","MQTTX v1.4.2 正式发布 - 跨平台 MQTT 5.0 桌面客户端","MQTT X v1.4.2 正式发布，新增脚本功能、Client ID 自动加入时间戳，并优化了部分功能。","2020-12-19","https://assets.emqx.com/images/8a061565b6d6ce57580c371bc27b63dc.png","1.4.2",{"slug":2229,"title":2230,"description":2231,"date":2232,"category":2026,"cover":2233,"version":2234},"mqttx-v-1-3-1-release-notes","MQTTX v1.3.1 发布 - 跨平台 MQTT 5.0 客户端工具","该版本新增： MQTT 5.0 更多属性、单击已订阅的 Topic 项实现消息过滤、点击 Topic 名称后快速复制 Topic 信息、启用严格的证书验证选项。","2020-05-15","https://assets.emqx.com/images/daebe4ee5cf1a736923d821c30949aa2.png","1.3.1",{"slug":2236,"title":2237,"description":2238,"date":2239,"category":2026,"cover":2240,"version":2241},"mqttx-v1-3-0-was-officially-released-an-elegant-cross-platform-mqtt5-desktop-test-client","MQTTX v1.3.0 正式发布 - 跨平台 MQTT 5.0 桌面测试客户端","MQTT X 是由 EMQ 开源的一款跨平台 MQTT 5.0 桌面测试客户端，它支持 macOS，Linux，Windows。用户可以使用 MQTT X 快速创建多个同时在线的 MQTT 客户端，方便测试 MQTT/TCP、MQTT/TLS 的连接/发布/订阅功能及其他 MQTT 协议 特性。","2020-03-19","https://assets.emqx.com/images/a6221d0ffcaad5c8019e239340833f44.png","1.3.0",1793585626579]