Data Sync Overview

Update time: 2022/12/08 06:15:41

The CommsEase server provides the Data Sync service, which synchronizes your application's messages, events, and other data to the server that you specified, meeting your needs for local storage of business data.

How it works

The process of Data Sync is as follows:

  1. The application clients send and receive data such as messages and event notifications through the CommsEase server.
  2. The CommsEase server sends an HTTP-POST request to the application server (the request body in JSON format carries the data to be synchronized).
  3. After the request is authorized, the application server parses the POST request to obtain the corresponding data.

消息抄送服务_英文.png

The server that receives the synchronized data can be your application server or a third-party server. The above diagram is only an example showing the data synchronization process when your application is specified as the server that receives the data.

Prerequisites

Subscribe to the service

You need to go to the CommsEase console to subscribe to the service before you can use it.

Implement certain logic on the specified server

Before using the Data Sync service, it is recommended that you implement the following logic to process the received data on the specified server.

Logic
Description
Asynchronous mechanism
  • The timeout period for Data Sync is 5 seconds. If the specified server returns the status code 200 or 500 in 5 seconds after receiving the HTTP-POST request from the CommsEase server, the synchronization is successful, otherwise failed. Therefore, if time-consuming operations (such as database storage) need to be performed after the specified server receives the synchronized data, you need to implement an asynchronous mechanism (e.g., store the data in the message queue first) on the API of the specified server to avoid the CommsEase server determines that the synchronization has timed out.
  • If the synchronized data cannot be discarded, please contact the business manager through the contact information provided on the homepage of CommsEase's official website to activate the Reliable Data Sync service. After activation, if data synchronization fails, the NetEase CommsEase server will try to resynchronize up to 1,000 times.
    If the specified server still fails to respond after resynchronization, the NetEase CommsEase server will cache up to 500,000 messages. In this case, you need to synchronize data manually after the specified server is restored to normal.
Deduplication mechanism Considering the instability of the network environment, CommsEase might send the same data repeatedly. It is recommended that you implement a specific deduplication mechanism for the received data.

Request format

Content-Type of the Data Sync request is application/ json rather than application/x-www- form- urlencoded.

Request header settings

The following parameters are required in the request header, among which MD5 and CheckSum are used for verifying whether the data is tampered with during transmission.

Parameter type Description
AppKey String App Key of the application
CurTime String The current UTC timestamp since 0:0:00, January 1, 1970 (unit:millisecond)
CheckSum String sha1( AppSecret + MD5 + CurTime ), where the AppSecret value is the application's App Secret
MD5 String The value calculated according to the request body, that is, MD5 = md5(request body)

MD5 calculation example

String requestBody = "{}" ;
String MD5 = CheckSumBuilder.getMD5( requestBody ); 

CheckSum calculation example

String AppSecret = "90u757h67n87"; 
String MD5 = "9894907e4ad9de4678091277509361f7";
String CurTime = "1440570500855";  ////Current UTC timestamp (String)
String CheckSum = CheckSumBuilder.getCheckSum(AppSecret, MD5, CurTime); 

For more information about CheckSum calculation, see Overview.

Data sync types

1). "eventType"="1", indicating CONVERSATION message, i.e. message of session type (currently including peer-to-peer in-session messages & User-defined system notifications, group chat in-session messages & User-defined system notifications and CommsEase built-in system notifications)

2). "eventType"="2", indicating LOGIN message, i.e. message for user login event

3). "eventType"="3", indicating LOGOUT message, i.e. message for user logout/offline event

4). "eventType"="4", indicating CHATROOM message, i.e. message for chat in a chat room

5). "eventType"="5", indicating AUDIO/VEDIO/DataTunnel message, i.e. message reporting the duration of live audio & video calls and whiteboard event

6). "eventType"="6", indicating audio/video/whiteboard file storage message, i.e., message reporting the size of the audio/video/whiteboard file, download URL and other messages

7). "eventType"="7", indicating recall of one-to-one chat message

8). "eventType"="8", indicating recall of group chat message "eventType"="25", indicating recall of Supergroup chat message

9). "eventType"="9", indicating CHATROOM\_INOUT message, i.e., message reporting the event the host or administrator joins or leaves the chat room

10). "eventType"="10" / "type": "CALL", indicating ECP\_CALLBACK message, i.e., message reporting callback at the end of special line call

11). "eventType"="11", indicating SMS\_CALLBACK message, i.e., message reporting SMS receipt

12). "eventType"="12", indicating SMS\_REPLY message, i.e., message reporting SMS uplink

13). "eventType"="13", indicating AVROOM\_INOUT message, i.e., message reporting AVROOM/whiteboard room INOUT.

14). "eventType"="14", indicating CHATROOM\_QUEUE\_OPERATE message, i.e. message reporting chat room queue operation

15). "eventType"="20", indicating that the details of the "checked" anti-spam messages among asynchronous anti-spam messages from GuardEase are only copied. It currently supports three types of voice and video messages: one-to-one, group chat, and chat room

16). "eventType"="21", indicating Audio & Video Call 2.0 AUDIO/VEDIO message, i.e. message reporting the duration of Audio & Video Call 2.0 live audio & video calls

17). "eventType"="22", indicating Audio & Video Call 2.0 audio/video file storage message, i.e., message reporting the size of the Audio & Video Call 2.0 audio/video file, download URL and other messages

18). "eventType"="23", indicating message reporting the event that Audio & Video Call 2.0 users join or leave 1 AVROOM

19). "eventType"="26", indicating message reporting the event that the AVROOM is over

20). "eventType"="27", indicating message reporting the event that Audio & Video Call 2.0 AVROOM is over

21). "eventType"="28", indicating message reporting the event that AVROOM is enabled

22). "eventType"="29", indicating message reporting the event that the Audio & Video Call 2.0 AVROOM is enabled

23). "eventType"="30", indicating that a peer-to-peer message has been read and copied

24). "eventType"="31", indicating independent signal

25). "eventType"="35", indicating real-time audio RTMP

26). "eventType"="36", indicating upload task

27). "eventType"="42", indicating keep-alive connection and heartbeats

Was this page helpful?
Yes
No
  • How it works
  • Prerequisites
  • Subscribe to the service
  • Implement certain logic on the specified server
  • Request format
  • Request header settings
  • MD5 calculation example
  • CheckSum calculation example
  • Data sync types