← All demos

TURN servers

Choose how the SDK finds TURN relay servers, then publish or view a test stream and check whether the peer connection is direct or relayed through TURN.

  1. Pick a TURN mode (tick Force TURN to send everything through a relay) and press Connect.
  2. Press Publish camera, then open the share link in a second tab or on another device.
  3. In the second tab, press Connect, then View. The stream ID is filled in from the link.
  4. Read Connection path. "Relayed" means media goes through a TURN server; "Direct" means it does not.

TURN configuration

Not connected

TURN settings apply when the SDK is created. Disconnect to change them.

Connection test

Key SDK calls in this demo
// TURN options are read when the SDK is created
const sdk = new VDONinjaSDK({
    turnServers: [{ urls: ['turn:turn.example.com:3478'], username, credential }],
    // turnServers: false  -> STUN only;  omit it -> auto-fetch from VDO.Ninja
    forceTURN: true        // iceTransportPolicy 'relay': every connection uses TURN
});
await sdk.connect();
await sdk.joinRoom({ room });
await sdk.publish(cameraStream, { streamID });   // tab 1
await sdk.view(otherStreamID, { video: true });  // tab 2

const quality = await sdk.getPeerQuality(uuid);  // { relayed, candidatePairType, rttMs, ... }
sdk.clearTURNCache();                            // next connection fetches a fresh list