Reverse Remote Procedure Call (RRPC) lets you use custom topics to communicate with IoT Platform. RRPC topics incorporate your custom topics to support communication in various scenarios.
Prerequisites
To develop a device that communicates with IoT Platform by using custom topics, use one of the following Link SDKs: C Link SDK.
Custom topics
| Topic | Format | Description |
| RRPC subscription | /ext/rrpc/+/${topic} |
Subscribe to the custom topic in the RRPC request message sent by IoT Platform. |
| RRPC request message | /ext/rrpc/${messageId}/${topic} |
The RRPC request message sent by IoT Platform. |
| RRPC response message | /ext/rrpc/${messageId}/${topic} |
The RRPC response message sent by the device. |
The topic format uses the following variables:
- ${topic}: The complete custom topic in IoT Platform. The format is
/${productKey}/${deviceName}/user/${TopicShortName}.${TopicShortName}is the suffix of the custom topic and specifies the topic category. For more information, see Use custom topics for communication. - ${messageId}: A unique RRPC message ID generated by IoT Platform when the server calls the RRpc API operation to send a message to the device. Use this ID to distinguish between different RRPC messages.
For example, if the custom topic for the device device1 is a18wP***/device1/user/get, the topic for sending an RRPC message is /ext/rrpc/121307410***/a18wP***/device1/user/get.
Connect with RRPC
- Send an RRPC message from IoT Platform.
The server calls the RRpc API of IoT Platform to send a message to the device. For more information, see RRpc.
The following example shows how to call the API by using the Java SDK for IoT Platform.
If you use the custom topic format, make sure the IoT Platform Java SDK for cloud (aliyun-java-sdk-iot) is version 6.0.0 or later.
<dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-iot</artifactId> <version>6.0.0</version> </dependency>Example of calling the RRpc API:
RRpcRequest request = new RRpcRequest(); request.setProductKey("testProductKey"); request.setDeviceName("testDeviceName"); request.setRequestBase64Byte(Base64.getEncoder().encodeToString("hello world")); request.setTopic("/testProductKey/testDeviceName/user/get");// If you use a custom topic, pass the custom topic here. request.setTimeout(3000); RRpcResponse response = client.getAcsResponse(request);Note You can also log on to the OpenAPI Developer Portal to call the RRpc API online and view call examples for IoT Platform cloud SDKs in different languages. - Configure the device.
No special configuration is required for devices that use the C Link SDK.
- The device sends an RRPC response.
The request topic and response topic for an RRPC call are the same. The device sends the response to the same topic from which it received the request.
Note Devices can send RRPC response messages only with a Quality of Service (QoS) level of 0.