Because the Message Queuing Telemetry Transport (MQTT) protocol uses a publish/subscribe-based asynchronous communication method, this protocol is not suitable for scenarios where the server need to synchronously send requests to devices and receive responses from the devices. In response to the issue, IoT Platform enables synchronous request and response communication without the need to modify the MQTT protocol. To do so, the server calls the IoT Platform API.

Terminology

  • RRPC: RRPC is short for Revert-RPC. RPC (Remote Procedure Call) uses a form of client–server interaction, and allows you to execute a procedure in a remote place without knowing the details for the remote interaction. RRPC allows you to send a request to a specified device and receive a response from the device.
  • RRPC request message: The message that is sent to a device from the cloud.
  • RRPC response message: The response message that is sent to the cloud from a device.
  • RRPC message ID: A unique message ID that is generated by IoT Platform for each RRPC request.
  • RRPC subscription topic: A topic that a device subscribes to for RRPC messages. The topic includes a wildcard (+).

Message communication using RRPC



  1. When IoT Platform receives an API call from the server, it sends an RRPC request message to the device. The message body is any input data, and the topic is the topic defined by IoT Platform, which includes the unique RRPC message ID.
  2. After the device receives the request message, it returns an RRPC response message to the cloud according to the defined topic format, and including the RRPC message ID. IoT Platform extracts the message ID from the topic, matches the ID with the ID of the request, and then sends the response to the server.
  3. If the device is offline when the call is performed, IoT Platform returns an error message to the server indicating that the device is offline. If the device does not send any response message within the timeout period (eight seconds), IoT Platform then returns a timeout error to the server.

Topic format

Topics are implemented in different formats for different methods.