livekit-client@v2.15.13 how do I force it to use t...
# ask-ai
p
livekit-client@v2.15.13 how do I force it to use tcp only from the browser
t
Thanks for reaching out, mithun. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your question about forcing
livekit-client@v2.15.13
to use TCP only from the browser. You can force TCP-only WebRTC connectivity by telling the browser to use only relay candidates (i.e., TURN) when creating the PeerConnection. Set
iceTransportPolicy: 'relay'
via the
rtcConfig
option when calling `room.connect()`:
Copy code
import { Room } from 'livekit-client';

const room = new Room();

await room.connect(
  '<wss://your-livekit-server.com>',
  'your-access-token',
  {
    rtcConfig: {
      iceTransportPolicy: 'relay', // forces use of TURN (TCP/TLS) only
    },
  }
);
Why this works •
iceTransportPolicy: 'relay'
prevents direct host/srflx (UDP) candidates and forces the peer connection to use TURN relays. TURN servers reachable over TCP/TLS (typically on port 443) will provide TCP-based connectivity that works through restrictive firewalls. Important notes • You must have a TURN server configured that supports TURN over TCP/TLS (port 443). If the TURN server only provides UDP, the connection will fail. • Ensuring your LiveKit server / media node exposes TURN/TLS is required so clients can establish TCP/TLS relayed media. • This setting applies to browser WebRTC behavior — it does not change any server-side transport behavior. If you’d like, tell me: • whether you already have TURN/TLS configured on your LiveKit deployment (hostname/port), and • whether you’re seeing failed connections now (any browser console logs or SDP/ICE debug output). I can then help verify your TURN configuration or walk through debugging steps. Sources: Firewall Tips for LiveKit Connectivity | LiveKit | Diagnosing Connection Errors with the Connection Test Utility | LiveKit