Network quality 🔗

This feature is part of OpenViduPRO tier.

One of the most important elements in real-time WebRTC connections is the network. It can have a huge impact in the quality of the media streams being transmitted. Usually we have control over the quality of the server-side network, but we don't have any guarantee about the network of the clients. For that reason, it is especially important to monitor and to be able to warn about network problems to our end users.

By making use of the WebRTC stats, OpenVidu offers a very simple API to monitor client-side network qualities and warn affected users. It allows to receive events in the application's client-side to notify users about their own network quality, as well as other user's network qualities. A common way of notifying this in the UI of the app is drawing a network icon, filling it for displaying good networks and emptying it for displaying poor networks.




Enabling the network quality API 🔗

OpenVidu network quality is only available for PUBLISHERS. You can only receive the network quality level for participants publishing a media stream. Participants that only receive remote streams will not generate network quality events.

To be able to receive the network quality events in your application's client-side, you must enable OpenVidu Pro configuration property OPENVIDU_PRO_NETWORK_QUALITY. You can also set the frequency with which OpenVidu Server Pro will check the network quality of each participant with property OPENVIDU_PRO_NETWORK_QUALITY_INTERVAL.

OPENVIDU_PRO_NETWORK_QUALITY=true
OPENVIDU_PRO_NETWORK_QUALITY_INTERVAL=5

After that, you can start receiving network quality events in the application's client side by adding listener networkQualityLevelChanged to the Session object. This listener is able to receive events of type NetworkQualityLevelChangedEvent.

session.on('networkQualityLevelChanged', event => {

    if (event.connection.connectionId === session.connection.connectionId) {
        console.log("Now my network quality level is " + event.newValue + ". Before was " + event.oldValue);

        // Do stuff

    } else {
        console.log("Network quality level of connection " + event.connection.connectionId
            + " is " + event.newValue + ". Previous one was " + event.oldValue);

        // Do stuff

    }
});



Understanding the network quality result 🔗

The NetworkQualityLevelChangedEvent provides in properties newValue and oldValue a number between 0 and 5, with the current and previous value of the network quality level respectively. The following table summarizes the meaning of those numbers:

Network quality level Meaning
0 The network is broken
1 The network is bad
2 The network is poor
3 The network is non optimal
4 The network is good
5 The network is excellent