boundless-author-7811
05/18/2026, 11:28 AMtall-airline-16756
05/18/2026, 11:28 AMtall-airline-16756
05/18/2026, 11:29 AMboundless-author-7811
05/18/2026, 11:34 AMtall-airline-16756
05/18/2026, 11:35 AMegress.start_failed — Server disconnected.
Short answer: LiveKit egress won’t automatically requeue failed start requests. You should implement retry/requeue logic in your backend. Here’s a minimal, safe pattern to follow:
• Capture the failed start response and log the error + the original request payload.
• Add an idempotency key to every egress request (a UUID you control) so retries won’t create duplicate output.
• Retry automatically with exponential backoff (e.g., 1s, 2s, 4s, up to a max attempts limit).
• If you need durable retries, write the request (with idempotency key and metadata) to a persistent queue/job store (Redis, RabbitMQ, SQS, or a DB-backed job queue) and let workers re-attempt until success or max attempts.
• Use egress webhooks (egress_started / egress_ended) as the source of truth: if no started webhook arrives after your start request, it’s safe to retry.
• On network/service flakiness, prefer queue-based retries rather than tight synchronous retries to avoid blocking your app.
If you want, I can:
• Provide a short example (pseudo-code or your preferred language) showing idempotent start + exponential backoff.
• Suggest a minimal durable queue setup (Redis or DB) tailored to your stack.
Which would you like?
Sources: Universal Egress | LiveKit | Why is my Agent insights data missing? | LiveKit, with interactive elementstall-airline-16756
05/18/2026, 11:37 AMlkapi.egress.start_room_composite_egress and logs egress.start_failed on exceptions. Below is a concise, safe pattern you can apply to requeue/retry when the egress server disconnects.
Key points first
• LiveKit egress does not auto-requeue failed start requests. Retry from your backend.
• Use an idempotency key so retries won’t create duplicate recordings.
• Prefer exponential backoff + a max attempts limit.
• For durability use a persistent queue/job store (Redis/RabbitMQ/SQS/DB) so retries survive process restarts.
• Use egress webhooks (egress_started, egress_ended) as the source of truth: if no egress_started webhook arrives, it’s safe to retry.
Suggested minimal changes (pseudo-Python)
1. Add an idempotency key to the request metadata (generate and persist it with the job).
2. On exception, enqueue the job into a durable queue instead of dropping it.
3. Worker consumes the queue, retries with exponential backoff and stops after N attempts.
4. Before each retry, check whether an egress_started webhook for the idempotency key / request has already arrived.
Example outline (concise)
• Generate idempotency key and persist with request record.
• Try synchronous start once.
• On failure, push job to persistent queue with attempt=1.
• Worker loop:
a. Pop job.
b. If attempts > MAX -> mark failed and alert.
c. Call start_room_composite_egress with same idempotency key.
d. If success -> done.
e. If fails -> increment attempts, schedule requeue after backoff (sleep or delayed queue).
Idempotency details
• Store idempotency key with any output location metadata (S3 path) and job state.
• If a start call actually succeeded but the client didn't observe it, webhook egress_started will arrive—use that to mark job complete and avoid retrying.
Backoff suggestion
• Exponential backoff: 1s, 2s, 4s, 8s… cap at 30–60s and max attempts 5–8 depending on tolerance.
If you want, I can:
• Provide a concrete, tested Python snippet (integrated with Redis or RQ/Celery) that wraps your posted function and implements idempotency + retries + webhook-checking. Which queue/backend would you prefer?, with interactive elements