Skip to main content

Network Probe

Supported from SDK version 5.2.5.

The startNetworkProbe method allows users to perform network quality probing before joining an RTC room. It provides real-time feedback on round-trip latency, uplink/downlink packet loss rates, and network quality metrics through corresponding callbacks.

tip

Complete network quality probing before joining a room. The SDK does not support network probing during ongoing RTC calls.

Enable RTC Network Probe

Call the startNetworkProbe method of the RCRTCEngine object to initiate network quality probing. Implement the onNetworkProbeUpLinkStats, onNetworkProbeDownLinkStats, and onNetworkProbeFinished methods to receive related events.

engine.onNetworkProbeStarted = (int code, String? errMsg) {
if (code == 0) {
// Network probe started successfully
}
};
// Start network probing
engine.startNetworkProbe(this);


void onNetworkProbeUpLinkStats(RCRTCNetworkProbeStats stats) {
// Reports uplink network probe data
}


void onNetworkProbeDownLinkStats(RCRTCNetworkProbeStats stats) {
// Reports downlink network probe data
}


void onNetworkProbeFinished(int code, String? errMsg) {
// Network probe completed (code 0 indicates normal termination, non-zero indicates interruption)
}

Initiate RTC Network Probe

Before joining a room, call startNetworkProbe to begin network quality probing. Upon successful initiation, registered callbacks will report probe results approximately every 2 seconds, including bandwidth, packet loss, jitter, and round-trip latency metrics for both uplink and downlink.

The total probing duration is approximately 30 seconds. After this period, probing automatically stops, triggering the onNetworkProbeFinished callback with code 0 to notify the application.

tip

Calling APIs like joinRoom or unInit before automatic termination (onNetworkProbeFinished code == 0) will interrupt ongoing probing, resulting in a non-zero callback code.

Example code:

engine.onNetworkProbeStarted = (int code, String? errMsg) {
if (code == 0) {
// Network probe started successfully
}
};

// Start network probing
engine.startNetworkProbe(this);

Terminate RTC Network Probe

Probing automatically stops after ~30 seconds. To force termination earlier, call the stopNetworkProbe method.

// Callback for stopping network probe
engine?.onNetworkProbeStopped = (int code, String? errMsg) {
if (code == 0) {
// Network probe stopped successfully
}
};

// Stop network probing
engine.stopNetworkProbe();