请求方还可以在请求中携带关联数据 (Correlation Data),响应方必须在响应中将关联数据原封不动地返回,请求方因此可以识别响应所属的原始请求。 这可以避免在响应方没有按请求顺序返回响应或者由于网络连接断开导致丢失了某个响应 (QoS 0) 时,请求方不正确地关联响应与原始请求。 另一方面,请求方可能需要与多个响应方交互,譬如
mqttx pub--client-idresponder--topicresponse/requester1--message"This isaresponse"--correlation-datarequest-1 在第二个终端窗口中,请求方收到响应消息: {"topic":"response","payload":"This is a response","packet": { ..."properties": {"correlationData": {"type":"Buffer","data": [114,101...
很显然MQTT也是这么考虑的,所以为PUBLISH报文新增了一个对比数据(Correlation Data)属性。响应信息 前面已经提到,可能存在多个请求方同时发起请求的情况,为避免不同请求方之间的冲突,请求方客户端使用的响应主题最好对于该客户端是唯一的。由于请求方和响应方通常都需要对这些主题进行授权,因此使用随机主题名称将会对...
最常用的办法就是在请求消息中携带一个特征字段,响应方在响应时将收到的字段原封不动地返回,请求方在收到响应消息时就可以根据其中的特征字段来匹配相应的请求。很显然MQTT也是这么考虑的,所以为PUBLISH报文新增了一个对比数据(Correlation Data)属性。 响应信息 前面已经提到,可能存在多个请求方同时发起请求的情况,为...
MQTT5.0为了支持request/response 模式在publish报文提供ResponseTopic字段以及Correlation Data属性。 客户端A pub主题为testA的消息,clientB订阅并收到,如果pub的属性字段有response topic:testrsp那么clientB会pub主题为testrsp的消息字段,订阅该主题的客户端将会收到。
PUBLISH QoS: 0 Topic: $iothub/responses Correlation_Data: 0x01 0xFA Payload: ... ReqRep 交互不支持将带 PUBLISH 的QoS: 1 数据包作为请求或响应消息。 发送请求 PUBLISH 会导致“Bad Request”响应。 Correlation Data 属性中支持的最大长度为 16 字节。 如果 Correlation Data 数据包上的 PUBLISH 属性...
//3.1.3.2.7 Correlation Data 【Binary Data】 //3.1.3.2.8 User Property【UTF-8 String Pair】 //3.1.3.3 Will Topic 【UTF-8 String】 //3.1.3.4 Will Payload【Binary Data】 //3.1.3.5 User Name【UTF-8 String】 //3.1.3.6 Password【Binary Data】 ...
correlationData: The Correlation Data is used by the sender of the Request Message to identify which request the Response Message is for when it is receivedbinary, userProperties: The User Property is allowed to appear multiple times to represent multiple name, value pairsobject ...
6 Response Topic【UTF-8 String】//3.1.3.2.7 Correlation Data 【Binary Data】//3.1.3.2.8 User Property【UTF-8 String Pair】//3.1.3.3 Will Topic 【UTF-8 String】//3.1.3.4 Will Payload【Binary Data】//3.1.3.5 User Name【UTF-8 String】//3.1.3.6 Password【Binary Data...
"correlation_data": "string", "user_properties": <{p> "foo": "bar" }, "content_type": "text/plain" }, "retain": false } 【5】MQTT客户端登录。 打开MQTT客户端,登录服务器,订阅api/example/topic主题。 【6】在API调试页面,点击执行 ...