TURN-only mode (relay mode) forces all WebRTC traffic through a TURN server, bypassing direct peer-to-peer connections. This is useful for:
This shows what types of ICE candidates are being gathered:
Test actual connection establishment using selected ICE policy:
const sdk = new VDONinjaSDK({
iceTransportPolicy: 'relay', // Forces TURN-only mode
turnServers: [
{
urls: 'turn:your-turn-server.com:3478',
username: 'your-username',
credential: 'your-password'
}
]
});
const sdk = new VDONinjaSDK({
iceTransportPolicy: 'relay'
});
const { pc, cleanup } = await sdk.quickView({
streamID: 'some-stream',
room: 'secure-room'
});
// All connections will use TURN relay
pc.onicecandidate = (event) => {
if (event.candidate) {
const candidate = event.candidate.candidate;
if (candidate.includes('typ host')) {
console.log('Host candidate (direct)');
} else if (candidate.includes('typ srflx')) {
console.log('Server reflexive (STUN)');
} else if (candidate.includes('typ relay')) {
console.log('Relay candidate (TURN)');
}
}
};