Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/UserGuide/Master/Table/API/Programming-MQTT.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,16 @@ Then, in your server:
5. Now IoTDB will use your implementation to parse the MQTT message.

More: the message format can be anything you want. For example, if it is a binary format,
just use `payload.forEachByte()` or `payload.array` to get bytes content.
just use `payload.forEachByte()` or `payload.array` to get bytes content.

## 7. Caution

To avoid compatibility issues caused by a default client_id, always explicitly supply a unique, non-empty client_id in every MQTT client.
Behavior varies when the client_id is missing or empty. Common examples:
1. Explicitly sending an empty string
• MQTTX: When client_id="", IoTDB silently discards the message.
• mosquitto_pub: When client_id="", IoTDB receives the message normally.
2. Omitting client_id entirely
• MQTTX: IoTDB accepts the message.
• mosquitto_pub: IoTDB rejects the connection.
Therefore, explicitly assigning a unique, non-empty client_id is the simplest way to eliminate these discrepancies and ensure reliable message delivery.
12 changes: 11 additions & 1 deletion src/UserGuide/Master/Tree/API/Programming-MQTT.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,15 @@ Then, in your server:
More: the message format can be anything you want. For example, if it is a binary format,
just use `payload.forEachByte()` or `payload.array` to get bytes content.


## 6. Caution

To avoid compatibility issues caused by a default client_id, always explicitly supply a unique, non-empty client_id in every MQTT client.
Behavior varies when the client_id is missing or empty. Common examples:
1. Explicitly sending an empty string
• MQTTX: When client_id="", IoTDB silently discards the message.
• mosquitto_pub: When client_id="", IoTDB receives the message normally.
2. Omitting client_id entirely
• MQTTX: IoTDB accepts the message.
• mosquitto_pub: IoTDB rejects the connection.
Therefore, explicitly assigning a unique, non-empty client_id is the simplest way to eliminate these discrepancies and ensure reliable message delivery.

15 changes: 15 additions & 0 deletions src/zh/UserGuide/Master/Table/API/Programming-MQTT.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,18 @@ public class CustomizedLinePayloadFormatter implements PayloadFormatter {

More: MQTT 协议的消息不限于 line,你还可以用任意二进制。通过如下函数获得:
`payload.forEachByte()` or `payload.array`。

## 7. 注意事项

为避免因缺省client_id引发的兼容性问题,强烈建议在所有MQTT客户端中始终显式地提供唯一且非空的 client_id。
不同客户端在client_id缺失或为空时的表现并不一致,常见示例如下:
1. 显式传入空字符串
• MQTTX:client_id=""时,IoTDB会直接丢弃消息;
• mosquitto_pub:client_id=""时,IoTDB能正常接收消息。
2. 完全不传client_id
• MQTTX:消息可被IoTDB正常接收;
• mosquitto_pub:IoTDB拒绝连接。
由此可见,显式指定唯一且非空的client_id是消除上述差异、确保消息可靠投递的最简单做法。



13 changes: 13 additions & 0 deletions src/zh/UserGuide/Master/Tree/API/Programming-MQTT.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,16 @@ public class CustomizedJsonPayloadFormatter implements PayloadFormatter {

More: MQTT 协议的消息不限于 json,你还可以用任意二进制。通过如下函数获得:
`payload.forEachByte()` or `payload.array`。


## 6. 注意事项

为避免因缺省client_id引发的兼容性问题,强烈建议在所有MQTT客户端中始终显式地提供唯一且非空的 client_id。
不同客户端在client_id缺失或为空时的表现并不一致,常见示例如下:
1. 显式传入空字符串
• MQTTX:client_id=""时,IoTDB会直接丢弃消息;
• mosquitto_pub:client_id=""时,IoTDB能正常接收消息。
2. 完全不传client_id
• MQTTX:消息可被IoTDB正常接收;
• mosquitto_pub:IoTDB拒绝连接。
由此可见,显式指定唯一且非空的client_id是消除上述差异、确保消息可靠投递的最简单做法。