All Products
Search
Document Center

IoT Platform:What is RRPC?

Last Updated:Dec 07, 2023

The Message Queuing Telemetry Transport (MQTT) protocol uses the asynchronous publish/subscribe model. This model is not applicable to the scenarios in which user servers need to synchronously control devices and obtain responses. IoT Platform provides a synchronous communication mechanism based on MQTT. You do not need to modify the MQTT protocol. IoT Platform provides the RRpc operation for user servers to send requests to devices. The devices only need to respond to the requests by using the specified topics and then the servers can synchronously obtain the responses.

Terms

TermDescription
RRPCRRPC is short for revert-RPC. A remote procedure call (RPC) uses the client-server model. This model allows you to request a remote service without the need to understand the underlying protocol. An RRPC allows you to send a request from a server to a device and receive a response from the device.
RRPC subscription-specific topicThe topic to which devices subscribe to receive RRPC messages. The topic includes a wildcard.
RRPC request messageThe message that IoT Platform sends to a device.
RRPC response messageThe message that a device sends to IoT Platform as a response.
RRPC message IDThe ID that is generated by IoT Platform for each RRPC message

How communication over RRPC works

RRPC

Process:

  1. Optional. A device subscribes to the RRPC subscription topic.

    IoT Platform can only send RRPC request messages and receive RRPC response messages based on MQTT. If a device needs to obtain and process RRPC data that is sent from IoT Platform, the device must subscribe to the preceding topic and implement the developed data processing logic.

    • The device can send the SUB command to subscribe to specified topics and obtain messages from IoT Platform. For information about the sample code that can be used to subscribe to a topic for a device, see Link SDKs.
    • For information about how a device processes RRPC data, see RRPC overview.
  2. A user server calls the RRpc operation of IoT Platform.
  3. IoT Platform receives a server-side RRPC request and sends an RRPC request message to the device. The message body includes the payload that is sent from the user server. The topic that is used by the device to receive RRPC messages is predefined in IoT Platform. The topic includes the ID of the message.
  4. After the device receives the message, the device sends an RRPC response message to IoT Platform by using the specified topic. The topic includes the ID of the request message.
  5. IoT Platform extracts the response message ID to match the previous RRPC request message.
  6. IoT Platform returns the response to the user server.
  7. Optional. The device processes messages from the topic to which the device subscribes to
Note When you call the RRpc operation, the following cases may occur:
  • The device is offline. In this case, IoT Platform returns an error message to the user server.
  • The device does not respond to the RRPC request within the timeout period (8 seconds). In this case, IoT Platform returns an error message to the user server.

RRPC-specific topics

You can implement RRPCs based on the following types of topics:

For information about the example of implementing an RRPC, see Remotely control a Raspberry Pi server.