Agora provides the Notification Center Service (NCS) to inform you of channel events in real time when you use the Real-time Communication (RTC) service.
The following figure illustrates how the Agora NCS works:
Before enabling the Agora NCS, ensure that you meet the following requirements:
Follow these steps to enable the NCS on the Agora Console:
Log in to Agora Console, and click the Project Management icon on the left navigation panel.
On the Project Management page, click Config for the project for which you want to enable the NCS.
Under Real-time engagement core, find Notification Center Service, and click Config.
On the Notification Center Service Configuration page, fill in the following information, and click Save:
Product Name: RTC channel event callbacks.
Event: Select the channel events that you want to subscribe to.
If the events that you want to subscribe to have high queries per second (QPS), such as events 105 and 106, ensure your server has sufficient processing capacity.
Agora recommends selecting all the events that you want to subscribe to at once to avoid multiple configurations and approval requests.
Receive Server Location: Select the region where your server that receives the notifications is located. Agora connects to the nearest Agora node server based on your specified location.
Receive Server URL: The HTTPS address of your server that receives the notifications.
MaxKeepAliveRequests
: 100 or more.KeepAliveTimeout
: 10 seconds or more.Secret: The secret used for signature verification. For instructions on how to use the secret for signature verification, see Signature verification.
Allowed IP List: If your server is behind a firewall, ensure that you have called the [IP address query API](#Get IP addresses of the Agora NCS server) to get the IP addresses of the Agora NCS server and added them to the firewall's allowed IP list, and check the box here.
Agora performs a health test for your configuration, as follows:
The NCS health test generates test events that correspond to your subscribed events, and then sends test event callbacks to your server. In test event callbacks, the channelName
is test_webhook
, and the uid
is 12121212
.
After receiving each test event callback, your server needs to respond to the Agora NCS server within 10 seconds with a status code of 200. The response body must be in JSON format.
When the NCS health test succeeds, click Save NCS Configuration.
If the NCS health test fails, follow the prompts on the Agora Console to troubleshoot the error. Common errors include the following:
Read the prompt, and click Save NCS Configuration.
After your configuration is approved, the Status of Notification Center Service shows Enabled.
If your server that receives notification callbacks is behind a firewall, you need to call the IP address query API to get the IP addresses of the Agora NCS server and configure your firewall to trust all these IP addresses.
Agora occasionally adjusts the IP addresses of the Agora NCS server. Therefore, Agora highly recommends that you call the IP address query API at least every 24 hours and automatically update the firewall configuration; otherwise, your server might not receive the notification callbacks.
GET
https://api.agora.io/v2/ncs/ip
Authorization
: You must generate a Base64-encoded credential with the Customer ID and Customer Secret provided by Agora, and then pass the credential to the Authorization
field in the HTTP request header. See HTTP authentication for details.
This API has no body parameters.
When the request succeeds, the response body looks like the following:
{
"data": {
"service": {
"hosts": [
{
"primaryIP": "xxx.xxx.xxx.xxx"
},
{
"primaryIP": "xxx.xxx.xxx.xxx"
}
]
}
}
}
Each primaryIP
field shows an IP address of the Agora NCS server. When you receive a response, you need to note the primaryIP
fields and add all these IP addresses to your firewall's allowed IP list.