Loading...
const pc = new RTCPeerConnection({
iceServers: [{ urls: 'stun.example.com:3478' }],
});const pc = new RTCPeerConnection({
iceServers: [{ urls: 'stun:stun.example.com:3478' }],
});ICE server URLs need the 'stun:' scheme; without it the constructor throws an error.
STUN only tells a device its public address so peers can connect directly. TURN relays all traffic when a direct path is impossible.
Port 3478 over UDP or TCP by default, and port 5349 for STUN over TLS.
It works, but public servers have no uptime guarantee. Production apps usually run their own or use a provider together with TURN.