testNetworkConnectivity(videoTrack: MediaStreamTrack): Promise;

The testNetworkConnectivity() method checks whether a stable connection can be established with our TURN server. This method is particularly useful during precall checks when a room has not yet been joined. The test is designed to automatically time out after 30 seconds. It returns a Promise that resolves to an object providing information about the connectivity test results:

  • "passed": The user’s browser and network successfully support connections to the TURN server.
  • "failed": Encountered issues when attempting to establish a connection to the TURN server.
  • "aborted": Indicates that the test was terminated before its completion.

Also see: abortTestNetworkConnectivity(). This method can be used to interrupt the test.

Note that this check is not indicative of whether you are "allowed" to join a call (i.e. have proper credentials or a valid room) but simply a check that the user can connect to our TURN servers.

When should I use this?

To effectively relay traffic between peers, most WebRTC applications require a server to function. This is because a direct RTCPeerConnection is not possible between clients unless they're on the same local network. To solve this so we can relay network traffic, we use a TURN server. Sometimes, people are behind strict corporate networks or VPNs that don't allow connections to TURN servers. Testing their network connectivity allows you to proactively address potential issues before a call is actually joined.

Why do I need to pass a video track?

In Chrome and Firefox, the network can be tested without a media track added to the peer connection. In Safari however, a media stream is required in order to test the connection. To make sure the test works in all browsers, we made the video track parameter required.

What do I do with the results?

Getting a "failed" result does not necessarily mean your users won't be able to have a video call at all — they might be able to have a P2P call. However, if you're running this test as part of a precall check, it is advisable to inform them they might experience issues, and they should contact their network administrator for support. You could point them to our network debugger for a more in-depth test.

Example usage of testNetworkConnectivity():

Related methods