Skip to content
ngTurn

Quickstart

Add ngTurn to any WebRTC app by listing its servers in your ICE configuration. There is no SDK to install.

  1. Create an API key in your dashboard and keep it on your server. Your backend calls the credentials endpoint and gets back a ready-made iceServers list. The key never leaves your server; the credentials it returns expire on their own.

  2. List UDP first for the lowest latency, then TCP and TLS on 443 as fallbacks for strict networks.

    ice-config.js
    const pc = new RTCPeerConnection({
    iceServers: [
    { urls: 'stun:relay.ngturn.io:3478' },
    {
    urls: [
    'turn:relay.ngturn.io:3478',
    'turn:relay.ngturn.io:3478?transport=tcp',
    'turns:relay.ngturn.io:443?transport=tcp',
    ],
    username: credentials.username,
    credential: credentials.credential,
    },
    ],
    });
    main.go
    config := webrtc.Configuration{
    ICEServers: []webrtc.ICEServer{{
    URLs: []string{"turn:relay.ngturn.io:3478", "turns:relay.ngturn.io:443?transport=tcp"},
    Username: username,
    Credential: credential,
    }},
    }
    pc, err := webrtc.NewPeerConnection(config)
  3. Open the TURN tester, paste the same URLs and credentials, and run it with relay-only gathering. A relay candidate means clients that need a relay will connect.

To test the relay path end to end, temporarily set iceTransportPolicy: 'relay'. Calls then connect only through ngTurn, which shows you exactly what users on locked-down networks experience.

Symptom Likely cause
Error 401 in the tester Wrong or expired credentials. Time-limited credentials expire by design.
Error 701 on UDP only The network blocks UDP. The TCP and TLS URLs should still work.
No relay candidates at all A proxy blocks port 3478 on both UDP and TCP. Keep turns: on 443 in your list: it looks like ordinary HTTPS.