← 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.
- Pick a TURN mode (tick Force TURN to send everything through a relay) and press Connect.
- Press Publish camera, then open the share link in a second tab or on another device.
- In the second tab, press Connect, then View. The stream ID is filled in from the link.
- Read Connection path. "Relayed" means media goes through a TURN server; "Direct" means it does not.
TURN configuration
Not connectedTURN settings apply when the SDK is created. Disconnect to change them.
Options passed to new VDONinjaSDK()
Connection test
You
Remote
Connection path
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