All Products
Search
Document Center

IoT Platform:FAQ about messaging

Last Updated:Nov 28, 2023

This topic provides answers to some frequently asked questions (FAQ) about the messaging between IoT Platform and devices or servers.

How does a device deduplicate messages when the device receives multiple messages that have the same content?

If the quality of service (QoS) level 1 is used for messaging, a message is received at least once. In this case, a device may receive duplicate messages that have the same ID. The device can deduplicate messages based on the message ID. Alibaba Cloud continuously updates IoT Platform to reduce the number of duplicate QoS 1 messages that are sent to devices.

What do I do when a device cannot receive messages after the device is connected to IoT Platform over Message Queuing Telemetry Transport (MQTT)?

If the device cannot receive messages, you can perform the following operations to troubleshoot the issue:

  • If the device does not receive messages, check whether the device subscribes to the required topic.

  • If the device does not receive several messages, check whether time-consuming logic exists in the callbacks of the device-side program. If time-consuming logic exists in the callbacks, we recommend that you implement the time-consuming logic in separate threads instead of the callbacks.

  • If the device uses an SDK for Android or Java, you must configure the device-side program to subscribe to the topic before the program executes the initialization. If initialization is complete before the device subscribes to the topic by using the SDK, the device cannot receive messages from IoT Platform.

  • If the device does not receive QoS 1 messages, check whether the cleanSession parameter in the MQTT connection information is set to false. You must set the cleanSession parameter to false to receive QoS 1 messages when the device is in the offline state.

Does IoT Platform store the messages that it receives?

IoT Platform stores the messages it receives based on the QoS level. After messages are sent to topics, IoT Platform forwards the messages to the devices that subscribe to the topics.

  • IoT Platform does not store QoS 0 messages.

  • IoT Platform stores QoS 1 messages for seven days.

Why does message delivery from IoT Platform time out?

Message latency and time-out issues may be caused by unstable network connections.

You can perform the following operations to test the network stability for device connection:

  1. Log on to the IoT Platform console.

  2. On the Overview page, find the instance that you want to manage and click the ID or alias of the instance to go to the Instance Details page.

  3. In the left-side navigation pane, choose Devices > Devices.

  4. Above the device list on the Devices page, enter the DeviceName or alias of the device to search for the device.

  5. Click View in the Actions column of the device to view the device information.

  6. On the Device Information tab, click Test next to Real-time Delay.

  7. In the dialog box that appears, click OK to test the network latency.

You can repeat Step 6 and Step 7 to perform multiple tests. If the latency is high, the network connection is unstable.

Does IoT Platform support will messages and retained messages?

Yes, IoT Platform supports will messages and retained messages. IoT Platform allows you to use MQTT 5.0 to specify will messages and retained messages. For more information, see MQTT 5.0 features that are supported by IoT Platform

How does a server obtain messages from devices?

A server can use one of the following methods to obtain messages from devices:

  • Server-side subscription: You can use the server-side subscription feature of IoT Platform to subscribe to messages of one or more types. IoT Platform forwards messages of specific types from all devices in a product to a server based on your subscription settings. To configure a server-side subscription, use one of the following methods:

    • Use an Advanced Message Queuing Protocol (AMQP) SDK to receive device data that is forwarded by IoT Platform. For more information, see AMQP server-side subscription.

    • Use a Message Service (MNS) SDK to receive device data that is forwarded by IoT Platform to MNS queues. For more information, see MNS server-side subscription.

  • Data forwarding: You can use the data forwarding feature to forward specific device data to MNS topics or Message Queue for Apache RocketMQ queues based on data forwarding rules. The server receives the device messages by using an MNS SDK or a Message Queue for Apache RocketMQ SDK. For more information, see Overview of data forwarding.

Why is an MNS queue unable to receive a message that I send in the IoT Platform console after I configure an MNS server-side subscription?

An MNS queue is unable to receive a message that you send in the IoT Platform console after you configure an MNS server-side subscription because the message is a server-side message. All messages that you send in the IoT Platform console or by calling IoT Platform API operations are considered server-side messages, and are not forwarded to MNS queues. Only messages that are sent by devices are forwarded to MNS queues. The messages include upstream device messages, and notifications of device status changes and device tag changes.

How do I identify the topic from which an MNS server receives a message?

View the content of the message. Sample message:

{
	"messageid": "12345",
	"messagetype": "status/upload",
	"topic": "null/topic",
	"payload": {},
	"timestamp": 1469564576
}

You can identify the topic from which an MNS server receives a message based on the value of the topic field.

How do I send messages from IoT Platform to devices?

You can call IoT Platform API operations to send messages from IoT Platform to devices. The following table describes the API operations that are supported.

API

Description

Pub

Sends a message to a device by using a custom topic.

BatchPub

Sends a message to multiple devices of a product at the same time by using a custom topic.

PubBroadcast

Broadcasts messages to online devices of a product.

You can specify all online devices or only the online devices that subscribe to a specific topic.

RRpc

Sends a request to a device and receives a response from the device in a synchronous manner.

SetDeviceProperty

Configures a Thing Specification Language (TSL) property for a device.

SetDevicesProperty

Configures a TSL property for multiple devices of a product.

InvokeThingService

Calls a TSL service on a device.

InvokeThingsService

Calls a TSL service on multiple devices of a product.