self hosted livekit using vm error when connecting...
# ask-ai
s
self hosted livekit using vm error when connecting to room: livekit:rtc engine405livekit:rtc_engine - failed to connect: Rtc(RtcError { error_type: Internal, message: "failed to initialize pc" }) default configurations from the init script
✅ 1
t
Thanks for reaching out, Youssef. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m sorry you’re hitting that error. You mentioned a self‑hosted LiveKit on a VM using the default init script and the error: livekit::rtc_engine - failed to connect: Rtc(RtcError { error_type: Internal, message: "failed to initialize pc" }) I can help troubleshoot. To narrow this down, a few targeted questions and quick checks will point to the most likely causes (network, time, auth, or VM resource issues): Please tell me or check the following: 1. Network & firewall ◦ Is your VM behind a cloud provider firewall, host firewall, or corporate NAT? Are inbound/outbound UDP ports allowed for media (commonly a UDP range like 50000–60000)? ◦ Can clients reach your server on the signaling URL (ws/wss) and on port 443? If UDP is blocked, do you have TURN configured and reachable over TCP/443? 1. TURN and ICE behavior ◦ Are you using LiveKit’s TURN or a custom TURN server? Is the TURN host reachable from the client network? ◦ Can you try forcing ICE relay (TURN) from the client to see if that succeeds? For example set the rtcConfig iceTransportPolicy to "relay" in the client connection options. 1. Time / JWT ◦ Have you confirmed the VM’s clock is accurate (NTP enabled)? JWT tokens are time sensitive; clock skew can cause failures. ◦ Are your LIVEKIT_API_KEY, LIVEKIT_API_SECRET and LIVEKIT_URL set correctly in the server and token generation code? 1. Logs & diagnostics ◦ Can you share the LiveKit server logs around the connection attempt (the few lines before/after the error)? Enabling more verbose logging temporarily can reveal why the PC failed to initialize. ◦ From a client machine, can you run the LiveKit Connection Test (https://livekit.com/connection-test) or use the SDK’s ConnectionCheck to test WebSocket, WebRTC, and TURN reachability? What do those checks report? 1. VM resources ◦ What kind of VM instance are you using (burstable vs fixed)? Burstable VMs can throttle CPU and sometimes cause timeouts or internal RTC errors. ◦ Any signs of CPU throttling or heavy load when the connection attempt happens? If you prefer, start with these quick steps and paste results here: 1. On the VM, confirm time sync: ◦
timedatectl status
and if needed
sudo timedatectl set-ntp true
1. From a client, run the Connection Test and share results or screenshots. 2. Share relevant server log lines (the error plus ~10 lines before/after). If you share the answers or those logs, I’ll walk through the next troubleshooting steps (firewall rules to check, how to test TURN reachability, or what specific log lines mean). Sources: Firewall Tips for LiveKit Connectivity | LiveKit | Diagnosing Connection Errors with the Connection Test Utility | LiveKit | Troubleshooting 401 Unauthorized and Token Errors | LiveKit | Troubleshooting 401 Unauthorized and Token Errors | LiveKit | Firewall Tips, with interactive elements