getNetworkStats()

getNetworkStats()

You can poll the getNetworkStats() method to continually read the current network performance.

Return type

Returns a Promise that resolves to a stats object with the following properties:

  • latest: a collection of statistics from the most recent time period. These statistics are updated approximately once every two seconds:
    • recvBitsPerSecond: total data from video and/or audio being received in bits per second
    • sendBitsPerSecond: total data from video and/or audio being sent in bits per second
    • timestamp: a unix timestamp (seconds since the epoch)
    • videoRecvBitsPerSecond: total data from video being received in bits per second
    • videoRecvPacketLoss: estimated data lost from the received video over a two second period
    • videoSendBitsPerSecond: total data from video being sent in bits per second
    • videoSendPacketLoss: estimated data lost from the video being sent over a two second period
    • totalSendPacketLoss: estimated data lost from the audio and video being sent over a two second period
    • totalRecvPacketLoss: estimated data lost from the received audio and video over a two second period
  • worstVideoRecvPacketLoss: the highest videoRecvPacketLoss number seen over a two second period during the call
  • worstVideoSendPacketLoss: highest videoSendPacketLoss number seen over a two second period during the call
  • threshold: 'good' | 'low' | 'very-low', an assessment of the current network quality. The threshold value is calculated from network stats averaged over an approximately 30-second rolling window. By default, we lower the bandwidth used for the call when the network quality drops to low, and we turn off the local camera when the network quality drops to very-low.
  • quality: a subjective calculation of the current network quality on a scale of 1-100.

To those building audio-only apps:

As noted by their property names, any key that includes video only applies to video. recvBitsPerSecond, sendBitsPerSecond, totalSendPacketLoss, and totalRecvPacketLoss, however, do cover both audio and video.

Sample response