I have deployed my app to production using Digital...
# ask-ai
l
I have deployed my app to production using DigitalOcean but the agent doesn't join the call or somethings it takes forever to join. What is the cause and how to solve it
t
Thanks for reaching out, Solomon. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I hear you: your agent on DigitalOcean either doesn’t join calls at all or takes a long time to join. I’ll walk through the most likely causes and actionable checks you can run right now, then ask a few targeted questions so I can help narrow the root cause. Key things to check now (quick diagnostics) 1. Check agent logs when a call arrives ◦ Look for errors around join, job-request, model loading, or network timeouts. ◦ Note any "room connection not established" or similar messages. 1. Confirm the agent process is running and registered ◦ Ensure the agent worker process is started (not just a console or one-off run). ◦ Verify logs show the agent connecting to LiveKit. 1. Verify network/TURN connectivity ◦ Run the LiveKit Connection Tester: https://livekit.io/connection-test ◦ Ensure TCP/443 outbound and UDP (WebRTC) are allowed from the droplet and that TURN endpoints (e.g., *.turn.livekit.cloud) are reachable. 1. Check dispatch settings (if using SIP/telephony) ◦ Confirm you have a dispatch rule that references the correct
agent_name
or room prefix. ◦ If
agent_name
is set in the agent, automatic dispatch is disabled — you must dispatch explicitly. 1. Observe whether models are loading slowly ◦ If your agent loads STT/LLM/TTS models on-demand, model load time can cause the 10s connection timeout. ◦ Prewarm models at startup or bake them into the container image to avoid per-call delays. Common causes and how to fix them • Agent worker not running or not registered ◦ Start the agent in production/dev mode and confirm it registers; ensure
agent_name
matches dispatch rules. • Network/firewall restrictions ◦ Allow outbound TCP/443 and UDP for WebRTC; ensure TURN is allowed. Use the connection test to identify failures. • Latency to AI services (STT/LLM/TTS) ◦ Deploy the agent in a region near the AI provider endpoints. ◦ Consider LiveKit Inference (co-locates model access) if you need lower latency. • Single or overloaded workers ◦ Run multiple workers per
agent_name
for redundancy and scaling. ◦ Increase CPU/memory or scale horizontally if workers are CPU-bound or slow. • 10-second dispatch timeout ◦ Prewarm models during agent startup or in a setup/prewarm function. ◦ Increase resources or pre-download model artifacts in your container image. What I need from you to diagnose further Please share any of the following (as available): • Recent agent logs around a call attempt (paste the relevant error block). • Are you using SIP/telephony or direct WebRTC? • The DigitalOcean region of your droplet. • Which AI providers you call for STT/LLM/TTS (OpenAI, Deepgram, ElevenLabs, etc.). • Whether you run a single worker or multiple workers per agent. If you can paste a short log snippet showing the join attempt and any error lines, I can point to the exact problem and a concrete fix. Sources: Agents telephony integration | LiveKit Documentation | SIP Lifecycle Management Agent | LiveKit Documentation | How can I reduce latency in voice agents using STT, TTS and LLM? | LiveKit | examples/drive-thru | livekit/livekit_composite | DeepWiki | Introducing LiveKit Inference: A unified model interface for voice AI
l
How to deploy livekit to digitalocean
t
Thanks — I can help you deploy LiveKit to DigitalOcean. Below are three practical options (Droplet VM, DigitalOcean Kubernetes, or using LiveKit Cloud), with step-by-step actions for the most common VM approach. Before I dive deeper, quick question: do you want a simple VM (Droplet) deployment or a Kubernetes (DOKS) deployment? Also, will you be running agents (AI/telephony) alongside the server? If you want the VM/Droplet route, follow these steps: 1) Prepare credentials and domain • Create a LiveKit project and get your
LIVEKIT_API_KEY
and
LIVEKIT_API_SECRET
. • Purchase a domain (or use an existing one) and plan to provision TLS (Let’s Encrypt is fine). 2) Prepare cloud-init (recommended for one-click Droplet setup) • Use the LiveKit cloud-init Ubuntu YAML template and edit it with your API key/secret and TLS cert/key. • Template source: https://github.com/livekit/livekit-server/blob/master/deploy/cloud-init.ubuntu.yaml • Place the edited YAML in the Droplet “User Data” field during creation so the server boots with LiveKit installed and configured. 3) Create the Droplet • Choose an Ubuntu LTS image. • Pick a region close to your users (and any AI services you’ll call). • Paste your edited cloud-init YAML into “User Data” and create the Droplet. 4) Configure DNS and TLS • Create an A record pointing your domain (e.g., livekit.example.com) to the Droplet public IP. • Ensure the TLS certificate and key are installed (cloud-init can install them if provided, or use Certbot after boot). 5) Open required firewall/ports • Allow TCP 443 (HTTPS / WSS). • Allow UDP for WebRTC (Media) and any additional LiveKit ports your deployment requires (check your cloud-init or server config for exact ports, commonly UDP/TCP 7882/7880/7881 depending on config). • Ensure outbound TCP/443 is allowed (for TURN, STUN, and API calls). 6) Verify the server • Use the LiveKit connection test: https://livekit.io/connection-test • Generate a test token and connect via a LiveKit SDK client to confirm publishing/subscribing works. 7) If you run agents or AI models • Deploy agents on droplets in regions near the AI provider endpoints (OpenAI, Deepgram, etc.) to reduce latency. • Prewarm models at startup or bake models into the container image to avoid per-call load delays. If you prefer Kubernetes (DOKS) • Create a DOKS cluster. • Install Helm and follow the LiveKit Kubernetes deployment guide. • Use an Ingress/LoadBalancer with TLS (Cert-Manager for Let’s Encrypt). • Helm charts and manifests let you scale LiveKit and manage rolling updates. Or use LiveKit Cloud (managed) • LiveKit Cloud handles scaling, TLS, and media routing for you and is the easiest path if you don’t want to manage infrastructure. What I can help with next • If you want, I can provide a ready-to-edit cloud-init YAML snippet tailored for DigitalOcean with placeholders for your API keys and TLS files. • Or I can walk you through the Kubernetes Helm commands for a DOKS install. • Tell me which option (Droplet vs DOKS vs Cloud) and whether you plan to run agents, and I’ll provide the exact next steps and example configs. Sources: Running LiveKit on AWS | Agent deployment overview | LiveKit Documentation
l
Here's my recent logs: Feb 20 111921 yarn run v1.22.22 Feb 20 111921 warning package.json: No license field Feb 20 111922 $ yarn agent:download && tsx agent.ts start Feb 20 111923 warning package.json: No license field Feb 20 111923 $ tsx agent.ts download-files Feb 20 111939 [dotenv@17.2.3] injecting env (0) from .env -- tip: ⚙️ override existing env vars with { override: true } Feb 20 111939 Starting Interview Agent... Feb 20 111939 LiveKit URL: wss://mock-interview-up2y2ttf.livekit.cloud Feb 20 111939 [111939.636] [32mINFO[39m (50): [36mDownloading files for turn-detector[39m Feb 20 112004 [112004.353] [32mINFO[39m (50): [36mFinished downloading files for turn-detector[39m Feb 20 112004 [112004.357] [32mINFO[39m (50): [36mDownloading files for silero[39m Feb 20 112004 [112004.357] [32mINFO[39m (50): [36mFinished downloading files for silero[39m Feb 20 112004 [112004.358] [32mINFO[39m (50): [36mDownloading files for deepgram[39m Feb 20 112004 [112004.358] [32mINFO[39m (50): [36mFinished downloading files for deepgram[39m Feb 20 112020 [dotenv@17.2.3] injecting env (0) from .env -- tip: ⚙️ load multiple .env files with { path: ['.env.local', '.env'] } Feb 20 112020 Starting Interview Agent... Feb 20 112020 LiveKit URL: wss://mock-interview-up2y2ttf.livekit.cloud Feb 20 112036 ERROR component agent exited with code: 128 Feb 20 112548 yarn run v1.22.22 Feb 20 112548 warning package.json: No license field Feb 20 112548 $ yarn agent:download && tsx agent.ts start Feb 20 112549 warning package.json: No license field Feb 20 112549 $ tsx agent.ts download-files Feb 20 112606 [dotenv@17.2.3] injecting env (0) from .env -- tip: ⚙️ suppress all logs with { quiet: true } Feb 20 112606 Starting Interview Agent... Feb 20 112606 LiveKit URL: wss://mock-interview-up2y2ttf.livekit.cloud Feb 20 112606 [112606.484] [32mINFO[39m (50): [36mDownloading files for turn-detector[39m Feb 20 112631 [112631.096] [32mINFO[39m (50): [36mFinished downloading files for turn-detector[39m Feb 20 112631 [112631.102] [32mINFO[39m (50): [36mDownloading files for silero[39m Feb 20 112631 [112631.102] [32mINFO[39m (50): [36mFinished downloading files for silero[39m Feb 20 112631 [112631.107] [32mINFO[39m (50): [36mDownloading files for deepgram[39m Feb 20 112631 [112631.108] [32mINFO[39m (50): [36mFinished downloading files for deepgram[39m Feb 20 112642 [dotenv@17.2.3] injecting env (0) from .env -- tip: ⚙️ enable debug logging with { debug: true } Feb 20 112642 Starting Interview Agent... Feb 20 112642 LiveKit URL: wss://mock-interview-up2y2ttf.livekit.cloud
t
Thanks — this is very helpful. I reviewed your logs and put together a focused diagnosis and concrete next steps to get your agent stable on DigitalOcean. What I’m responding to • The agent starts, downloads models (turn-detector, silero, deepgram), prints the LiveKit URL, then the process exits (one run shows “component agent exited with code: 128”). You’re seeing the agent not join calls or occasionally take too long. Short diagnosis • The agent successfully downloads files and reaches the LiveKit WSS URL, but then the process terminates with exit code 128 before we see successful registration or job dispatch. That usually means the process was terminated (e.g., by the runtime, a missing/invalid credential, an uncaught exception in startup logic, or a crash not logged at INFO level). There is no explicit authentication or connection success in the logs, so the failure is happening after model download but before a complete agent registration. Immediate actions to gather more signal (do these first) 1. Enable debug logging so we see the connection/auth flow and any exceptions: ◦ Start the agent with debug enabled (or increase log level). Example: add a debug/log flag your agent supports or set LOG_LEVEL=DEBUG before start. ◦ Reproduce the run and paste the debug output from just before “Starting Interview Agent...” until the crash. 1. Capture an expanded error trace: ◦ Run the agent interactively (not background) so stdout/stderr stay attached, e.g.
node agent.js
/
tsx agent.ts start
. ◦ If you use a container, run it with an interactive entrypoint and tail logs (
docker run --rm -it ...
). 1. Confirm runtime env vars are present and correct at process runtime: ◦ Verify
LIVEKIT_URL
,
LIVEKIT_API_KEY
,
LIVEKIT_API_SECRET
are set in the same environment used to start the agent (not just in .env files that may not be loaded at runtime). ◦ Confirm any AI provider keys (e.g.,
DEEPGRAM_API_KEY
) are set if the agent initializes those services on startup. Quick checks you can run now • Run: curl/wscat to the LiveKit WSS URL from inside the droplet to confirm outbound TLS connectivity: ◦ wscat example:
wscat -c <wss://mock-interview-up2y2ttf.livekit.cloud>
(or
curl -v <https://mock-interview-up2y2ttf.livekit.cloud/health>
if a health endpoint exists) • Check the process exit reason from the host (systemd/journald or Docker): ◦ For systemd:
journalctl -u your-agent.service -n 200 --no-pager
◦ For Docker:
docker logs <container-id> --details
• Confirm there’s no OOM/killed-by-kernel event: ◦
dmesg | grep -i kill
or
dmesg | grep -i oom
Likely root causes & targeted fixes 1. Missing/invalid API key or secret ◦ Symptom: agent can open a socket but is rejected when trying to authenticate/register. ◦ Fix: Ensure
LIVEKIT_API_KEY
and
LIVEKIT_API_SECRET
are present and correct in the runtime environment. If you recently rotated keys, update the deployed env. 1. Uncaught exception in startup code ◦ Symptom: silent exit after model load. ◦ Fix: Enable debug logs and run interactively to capture stack traces. Ensure
start
mode runs the server registration code path (
cli.runApp
or equivalent) — not a dev-only or download-only branch. 1. Network blocking or TLS handshake failure ◦ Symptom: WSS connect attempts may time out or be interrupted. ◦ Fix: Confirm outbound TCP/443 from the droplet is allowed. Ensure any company firewall or DO VPC rules permit outbound TLS to
*.livekit.cloud
. 1. Cold start/model load latency & dispatch timeout ◦ Symptom: agent takes too long to become ready and LiveKit dispatch times out. ◦ Fix: Pre-download models during image build (e.g., run
pnpm download-files
in your Dockerfile) or add a prewarm function so heavy models load at process start, not per-call. 1. Container/process lifecycle issues (if using Docker) ◦ Symptom: container exit code 128 due to entrypoint issues or signal handling. ◦ Fix: Ensure your Dockerfile uses a non-root user correctly, and the CMD/ENTRYPOINT forwards signals. Use a proper process manager or run directly in foreground so logs propagate. Concrete steps I recommend you run next 1. Re-run the agent with debug and paste the logs from the debug session (from startup through the exit). 2. Verify the environment variables are present to the running process: ◦ Example quick test inside the same environment:
node -e "console.log(process.env.LIVEKIT_API_KEY, process.env.LIVEKIT_URL)"
1. If running in Docker, update your Dockerfile to pre-download files: ◦ Add
RUN pnpm download-files
during build so downloads aren’t happening at runtime. 1. Check for OOM or kill events: ◦
dmesg | grep -i kill
and your container runtime logs. 1. If you see any auth or websocket error text in debug logs, paste it here and I’ll point to the exact fix. If you’d like, I can: • Provide a sample debug command and exact env-check commands for your agent runtime. • Provide an example Dockerfile snippet that pre-downloads assets and runs the agent in foreground with proper signal handling. Which would help most right now — do you want the exact commands to run for debug/log capture, or a ready-to-edit Dockerfile snippet to reduce cold-start problems? Sources: Agents (Node.js) | livekit/livekit_composite | DeepWiki | examples/voice_agents | livekit/livekit_composite | DeepWiki | server-sdk-js | livekit/livekit_composite | DeepWiki | Running LiveKit on AWS | Server options | LiveKit Documentation