started seeing this error when i deploy on Fargate...
# ask-ai
c
started seeing this error when i deploy on Fargate and the task is trying to stabilize: trying to deploy a livekit service to Fargate and getting this error: {"message": "worker failed", "level": "ERROR", "name": "livekit.agents", "exc_info": "Traceback (most recent call last):\n File \"/usr/local/lib/python3.12/asyncio/tasks.py\", line 520, in wait_for\n return await fut\n ^^^^^^^^^\n File \"/usr/local/lib/python3.12/site-packages/livekit/agents/ipc/channel.py\", line 47, in arecv_message\n return _read_message(await dplx.recv_bytes(), messages)\n ^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/site-packages/livekit/agents/utils/aio/duplex_unix.py\", line 35, in recv_bytes\n len_bytes = await self._reader.readexactly(4)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/asyncio/streams.py\", line 752, in readexactly\n await self._wait_for_data('readexactly')\n File \"/usr/local/lib/python3.12/asyncio/streams.py\", line 545, in _wait_for_data\n await self._waiter\nasyncio.exceptions.CancelledError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File \"/usr/local/lib/python3.12/site-packages/livekit/agents/cli/_run.py\", line 79, in _worker_run\n await worker.run()\n File \"/usr/local/lib/python3.12/site-packages/livekit/agents/worker.py\", line 402, in run\n await self._inference_executor.initialize()\n File \"/usr/local/lib/python3.12/site-packages/livekit/agents/ipc/supervised_proc.py\", line 169, in initialize\n init_res = await asyncio.wait_for(\n ^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/asyncio/tasks.py\", line 519, in wait_for\n async with timeouts.timeout(timeout):\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/asyncio/timeouts.py\", line 115, in __aexit__\n raise TimeoutError from exc_val\nTimeoutError", "timestamp": "2025-09-05T145741.313290+00:00"}
t
Thanks for reaching out, roni. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Could you share a bit more about your deployment setup? Specifically: • Which version of LiveKit are you working with? • Do you have any custom configurations or environment variables set for the Fargate task? • Have you made any recent changes to the deployment or service configuration? This info will really help us get to the bottom of the issue together.
c
livekit = "1.0.12" livekit-agents = {extras = ["playai", "groq"], version = "1.2.4"} livekit-plugins-silero = "1.2.4" livekit-plugins-deepgram = "1.2.4" livekit-plugins-openai = "1.2.4" livekit-plugins-google = "1.2.4" livekit-plugins-elevenlabs = "1.2.4" livekit-plugins-playai = "1.2.4" livekit-plugins-cartesia = "1.2.4" yes there are custom variables but we use them as env variables and the livekit env variables are the same as another deloyment that works fine: September 5, 2025 at 10:57 {"message": "worker failed", "level": "ERROR", "name": "livekit.agents", "exc_info": "Traceback (most recent call last):\n File \"/usr/local/lib/python3.12/asyncio/tasks.py\", line 520, in wait_for\n return await fut\n ^^^^^^^^^\n File \"/usr/local/lib/python3.12/site-packages/livekit/agents/ipc/channel.py\", line 47, in arecv_message\n return _read_message(await dplx.recv_bytes(), messages)\n ^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/site-packages/livekit/agents/utils/aio/duplex_unix.py\", line 35, in recv_bytes\n len_bytes = await self._reader.readexactly(4)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/asyncio/streams.py\", line 752, in readexactly\n await self._wait_for_data('readexactly')\n File \"/usr/local/lib/python3.12/asyncio/streams.py\", line 545, in _wait_for_data\n await self._waiter\nasyncio.exceptions.CancelledError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File \"/usr/local/lib/python3.12/site-packages/livekit/agents/cli/_run.py\", line 79, in _worker_run\n await worker.run()\n File \"/usr/local/lib/python3.12/site-packages/livekit/agents/worker.py\", line 402, in run\n await self._inference_executor.initialize()\n File \"/usr/local/lib/python3.12/site-packages/livekit/agents/ipc/supervised_proc.py\", line 169, in initialize\n init_res = await asyncio.wait_for(\n ^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/asyncio/tasks.py\", line 519, in wait_for\n async with timeouts.timeout(timeout):\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/asyncio/timeouts.py\", line 115, in __aexit__\n raise TimeoutError from exc_val\nTimeoutError", "timestamp": "2025-09-05T145741.313290+00:00"} slai-inbound-call-agent-develop September 5, 2025 at 10:57 {"message": "draining worker", "level": "INFO", "name": "livekit.agents", "id": "unregistered", "timeout": 1800, "timestamp": "2025-09-05T145741.315418+00:00"} slai-inbound-call-agent-develop September 5, 2025 at 10:57 {"message": "killing process", "level": "INFO", "name": "livekit.agents", "pid": 48, "inference": true, "timestamp": "2025-09-05T145741.312927+00:00"} slai-inbound-call-agent-develop September 5, 2025 at 10:57 2025-09-05 145731,316 - [92mINFO[0m - outbound-caller-runner - Application logging reconfigured with custom colored/structured handler. slai-inbound-call-agent-develop September 5, 2025 at 10:57 {"message": "initializing process", "level": "INFO", "name": "livekit.agents", "pid": 48, "inference": true, "timestamp": "2025-09-05T145731.302542+00:00"} slai-inbound-call-agent-develop September 5, 2025 at 10:57 {"message": "starting inference executor", "level": "INFO", "name": "livekit.agents", "timestamp": "2025-09-05T145726.555359+00:00"} slai-inbound-call-agent-develop September 5, 2025 at 10:57 {"message": "starting worker", "level": "INFO", "name": "livekit.agents", "version": "1.2.4", "rtc-version": "1.0.12", "timestamp": "2025-09-05T145726.536868+00:00"} slai-inbound-call-agent-develop September 5, 2025 at 10:57 {"message": "preloading plugins", "level": "INFO", "name": "livekit.agents", "packages": ["livekit.plugins.silero", "livekit.plugins.google", "livekit.plugins.openai", "livekit.plugins.deepgram", "livekit.plugins.groq", "livekit.plugins.cartesia", "livekit.plugins.elevenlabs", "livekit.plugins.playai", "livekit.plugins.turn_detector", "av"], "timestamp": "2025-09-05T145726.537009+00:00"} slai-inbound-call-agent-develop September 5, 2025 at 10:57 2025-09-05 145726,533 - [92mINFO[0m - inbound-agent - .env.local not found at /home/appuser/.env.local, using system environment variables slai-inbound-call-agent-develop September 5, 2025 at 10:57 2025-09-05 145726,534 - [92mINFO[0m - inbound-agent - Starting inbound agent worker 'inbound-caller-agent' with component architecture... slai-inbound-call-agent-develop September 5, 2025 at 10:57 2025-09-05 145726,534 - [92mINFO[0m - inbound-agent - Worker ready to handle inbound calls with enhanced performance and reliability slai-inbound-call-agent-develop September 5, 2025 at 10:57 2025-09-05 145722,816 - [92mINFO[0m - outbound-caller-runner - Application logging reconfigured with custom colored/structured handler. slai-inbound-call-agent-develop September 5, 2025 at 10:57 Skipping virtualenv creation, as specified in config file.
t
The error you're running into during LiveKit worker initialization on Fargate is probably due to CPU throttling or not having enough initialization timeout. No worries—here’s how you can fix it: 1. Use Non-Burstable Instance Types: Try switching to a non-burstable instance family like m5, c5, or c6i. These help avoid CPU throttling, which often happens with burstable instances such as t3 or t4g. 2. Monitor and Manage CPU Credits: If you need to stick with burstable instances, keep an eye on the CPUCreditBalance metric in CloudWatch to make sure you’re not running out of credits. You can also enable t3.unlimited mode to let your instance burst beyond the baseline when needed. 3. Increase Initialization Timeout: Try bumping up the initialize_process_timeout in the WorkerOptions to a bit higher—say, 20 to 30 seconds—to give slow initialization tasks like model loading some extra breathing room. Here’s a quick example:
Copy code
from livekit.agents import WorkerOptions

options = WorkerOptions(
    initialize_process_timeout=20.0  # Increase from default 10.0 seconds
)
This should help if the problem is due to slower startup processes. Feel free to reach out if you want a hand with these changes or have any other questions! Sources: Troubleshooting Latency and Timeout Errors with Turn Detection on AWS | livekit-plugins/livekit-plugins-gladia/livekit/plugins/gladia/stt.py