Skip to main content
testPeerToPeerCallQuality(options) Connects to Daily’s TURN servers and collects metrics over the test duration to indicate connection quality. Useful for precall checks before a room is joined. The test runs for 15 seconds by default (up to 30 seconds). The longer it runs, the more accurate the results. For in-depth network stats during a call, use getNetworkStats().

Parameters

videoTrack
MediaStreamTrack
required
A video track used to establish the test connection. You can obtain one from call.participants().local.tracks.video.persistentTrack after calling startCamera().
duration
number
default:"15"
How long to run the test in seconds. Maximum: 30.

Return value

Returns Promise<DailyP2PCallQualityTestResults>.
result
'good' | 'warning' | 'bad' | 'aborted' | 'failed'
Overall connection quality verdict:
  • 'good'avgRecvPacketLoss < 5%, avgRoundTripTime < 300ms, avgRecvBitsPerSecond ≥ 1,100kbps
  • 'warning'avgRecvPacketLoss 5–10%, avgRoundTripTime 300–600ms, avgRecvBitsPerSecond 700kbps–1,100kbps
  • 'bad'avgRecvPacketLoss ≥ 10%, avgRoundTripTime ≥ 600ms, avgRecvBitsPerSecond < 700kbps
  • 'failed' — connection to TURN servers could not be made; errorMsg and error fields are populated
  • 'aborted' — test stopped before data gathering started
secondsElapsed
number
Seconds over which data was collected.
data
DailyP2PCallQualityTestData
Stats used to determine the result. All averages use an exponential moving average biased toward the most recent data.
  • maxRoundTripTime (seconds) — maximum currentRoundTripTime
  • avgRoundTripTime (seconds) — average currentRoundTripTime
  • avgRecvPacketLoss (percentage) — average inbound packet loss
  • avgAvailableOutgoingBitrate (bps) — average availableOutgoingBitrate (not available on Firefox)
  • avgSendBitsPerSecond (bps) — average outbound bitrate
  • avgRecvBitsPerSecond (bps) — average inbound bitrate
errorMsg
string
Human-readable error message. Only present when result === 'failed'.
error
DailyFatalErrorObject
Structured error object. Only present when result === 'failed' and error details are available.

Example

await call.startCamera();
const videoTrack = call.participants().local.tracks.video.persistentTrack;

const results = await call.testPeerToPeerCallQuality({ videoTrack, duration: 10 });

switch (results.result) {
  case 'aborted':
    console.log('Test aborted before data was gathered.');
    break;
  case 'failed':
    console.warn('Test failed:', results.errorMsg);
    break;
  case 'bad':
    console.warn('Poor connection. Try a different network.');
    break;
  case 'warning':
    console.warn('Connection may be unstable.');
    break;
  case 'good':
  default:
    console.log('Connection quality is good.');
}

See also