Monitoring Network Quality - Javascript
VideoSDK gives you two ways to keep an eye on network conditions during a meeting:
- Participant network quality: the server measures every participant's connection and reports a quality level for what they send (uplink) and what they receive (downlink). Use it to show network indicators next to participants.
- Quality limitation: the
quality-limitationevent tells you when the local participant's media quality is reduced, or restored, because of CPU, bandwidth or congestion.
Participant Network Quality
network-quality-changed
-
This event is triggered with a participant's network quality, measured by the server, for both directions:
uplink: the connection from the participant to the server (the media they send).downlink: the connection from the server to the participant (the media they receive).
-
It can be subscribed to using the
participantobject, and works formeeting.localParticipantas well as remote participants. -
Adding the first
network-quality-changedlistener withparticipant.on()subscribes to that participant's network quality. Removing the last listener withparticipant.off()unsubscribes. -
A listener added before the meeting is joined subscribes once the meeting is joined.
-
The first event carries the current quality, once the server knows it. A listener added while the participant is already subscribed also receives the current quality. After that, the event is triggered whenever the
levelor thereasonsof either direction change, including when the connection recovers. -
The subscription is restored automatically after a reconnect.
Network quality data
The event receives { uplink, downlink }. uplink and downlink have the same shape:
| Property | Type | Description |
|---|---|---|
level | string | good, fair, poor, bad, or unknown. It is unknown when no media flows in that direction. |
score | number | From 1 (bad) to 5 (good). It is 0 when the level is unknown. |
reasons | array | Every signal pulling the level down, worst first. It is empty when the level is good or unknown. |
metrics | object | The raw values behind the level. A field is present only when it was measured. |
Possible values of reasons:
| Reason | Meaning |
|---|---|
packetLoss | High packet loss |
rtt | High round-trip time |
jitter | High jitter |
bandwidth | Not enough bandwidth |
stalled | Media has stalled |
Fields of metrics:
| Metric | Direction | Description |
|---|---|---|
packetLoss | Both | Packet loss, in %. |
jitter | Both | Audio jitter, in ms. |
rtt | Downlink | Round-trip time, in ms. |
availableBitrate | Downlink | The server's bandwidth estimate for the participant, in bps. |
limitedStreams | Downlink | Number of video streams forwarded below the quality the participant asked for. |
videoStreams | Downlink | Number of video streams the participant receives. |
activeLayers | Uplink | Number of simulcast layers the participant is sending now. |
peakLayers | Uplink | The most simulcast layers the participant has sent so far. |
Example
This example logs the network quality of every remote participant, and stops listening when they leave.
let meeting;
// Initialize Meeting
meeting = VideoSDK.initMeeting({
// Configuration options
});
function onNetworkQualityChanged({ uplink, downlink }) {
console.log(
`${peerId} uplink: ${uplink.level} [${uplink.reasons.join(", ")}],`,
`downlink: ${downlink.level} [${downlink.reasons.join(", ")}]`
);
}
meeting.on("participant-joined", (participant) => {
// Subscribes to this participant's network quality
participant.on("network-quality-changed", onNetworkQualityChanged);
});
meeting.on("participant-left", (participant) => {
// Removing the last listener unsubscribes
participant.off("network-quality-changed", onNetworkQualityChanged);
});
Getting the current network quality
participant.getNetworkQuality() returns the participant's last known { uplink, downlink }. The value is kept up to date while a network-quality-changed listener is attached.
const { uplink, downlink } = participant.getNetworkQuality();
console.log(uplink.level, downlink.level);
Quality Limitation
VideoSDK's quality-limitation event helps you stay informed whenever media quality is impacted or restored during a meeting. This allows you to take proactive steps and ensure a smooth user experience.
quality-limitation
-
This event is triggered whenever a media quality limitation is either detected or resolved during a meeting.
-
The callback includes a
typeparameter that specifies the cause of the quality limitation. Possible values:cpu: Quality is reduced due to high CPU usage.bandwidth: Quality is reduced due to insufficient bandwidth.congestion: Quality is reduced due to network congestion.
-
The callback also includes a
stateparameter that indicates the current status of the limitation:detected: A limitation has been identified.resolved: The limitation has been cleared.
-
A
timestampparameter is provided, representing the exact time (in milliseconds since epoch) when the event occurred. -
It can be subscribed to using the
meetingobject.
Example
Here is an example demonstrating the usage of the event mentioned on this page.
let meeting;
// Initialize Meeting
meeting = VideoSDK.initMeeting({
// Configuration options
});
// Subscribe to the quality-limitation event
meeting.on("quality-limitation", ({ type, state, timestamp }) => {});
API Reference
The API references for all the methods and events utilized in this guide are provided below.
Got a Question? Ask us on discord

