I'm using the egress api and i start recordings be...
# ask-ai
c
I'm using the egress api and i start recordings before the ctx.connect and the egress works fine but it always retries and it eats up my egress quota it always says "aborted" with error "Start signal not received"
t
Thanks for reaching out, Sebastian. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! To get to the bottom of the "Start signal not received" error, could you share a bit more about your setup? • What kind of egress are you using (room composite, web, participant, or track)? • Are you setting
await_start_signal
to true in your egress configuration? • What triggers do you expect to send the start signal? • Usually, how long does your app take from starting the egress to sending that start signal? Sources: rpc/egress_client.go | pkg/pipeline/controller.go | livekit-api/src/services/egress.rs | src/main/kotlin/io/livekit/server/EgressServiceClient.kt
c
1. I'm using the room Composite egress request: req = api.RoomCompositeEgressRequest( room_name=ctx.room.name, audio_only=True, file_outputs=[ api.EncodedFileOutput( file_type=api.EncodedFileType.OGG, filepath=filepath, disable_manifest=True, s3=api.S3Upload( bucket=s3_bucket, region=s3_region, access_key=s3_access_key, secret=s3_secret, ), ) ], ) lkapi = api.LiveKitAPI() response = await lkapi.egress.start_room_composite_egress(req) await lkapi.aclose() return response.egress_id 2. I am not aware of that 3. i start the recording as soon as the call starts 4. im not aware of any start signal let me know if my full code is needed
t
Thanks so much for sharing the details! From what you’ve described, it looks like the issue is related to how Room composite egress works by default. Unlike Web egress, Room composite egress doesn’t have an
await_start_signal
option. Instead, it relies on some automatic start detection rules: • If there are video tracks published, it waits for frames to be decoded. • If there are no video tracks published, it starts right away. • If it’s been more than 10 seconds, it records as long as there are tracks subscribed. Since you’re starting the recording as soon as the call begins, it’s possible the egress is timing out or not catching the start conditions quite right. Here are a few things you might try: 1. Make sure audio tracks are published to the room before kicking off the egress. 2. Try adding a little delay before starting the egress so all tracks have time to publish properly. 3. If you want more control over when recording starts, you could use a custom template with your own start conditions. Feel free to reach out if you want a hand with any of these steps or if you’d like to dive deeper into the custom template option—I’m here to help! Sources: livekit/livekit_egress.pb.go | template-default/src/Room.tsx | packages/livekit-server-sdk/src/EgressClient.ts
c
honestly i just want to avoid the aborted tries in the egress, here's my code, where are we failing? class Assistant(Agent): def __init__(self, custom_instructions: str | None = None) -> None: super().__init__( instructions=custom_instructions, ) def prewarm(proc: JobProcess): proc.userdata["vad"] = silero.VAD.load() _, session_maker = create_engine_and_session() proc.userdata["db_sessionmaker"] = session_maker async def entrypoint(ctx: JobContext): metadata = get_job_metadata(ctx) prompt = metadata.get("prompt") or DEFAULT_INSTRUCTIONS initial_message = metadata.get("initial_message") or DEFAULT_INITIAL_MESSAGE model = metadata.get("model") or DEFAULT_MODEL try: loaded = await load_from_metadata(metadata) prompt = loaded.prompt or prompt initial_message = loaded.initial_message or initial_message except Exception as e: logger.warning(f"config load failed: {e}") session = AgentSession( stt=deepgram.STT(model="nova-3", language="en-US"), llm=openai.LLM(model=model), tts=elevenlabs.TTS(voice_id="cjVigY5qzO86Huf0OWal", model="eleven_flash_v2_5"), vad=ctx.proc.userdata["vad"], turn_detection=EnglishModel() ) SessionLocal = ctx.proc.userdata["db_sessionmaker"] agent_config_ref = agent_config_ref_from(metadata) call_id = uuid.uuid4() await session.start( agent=Assistant(custom_instructions=prompt), room=ctx.room, room_input_options=RoomInputOptions( noise_cancellation=noise_cancellation.BVC() ), ) recording_key = f"{call_id}.ogg" egress_id = await record_call(ctx, recording_key) user_participant = await ctx.wait_for_participant() await ctx.connect() started_at = datetime.now(timezone.utc) await session.say(initial_message, add_to_chat_ctx=True) @ctx.room.on("participant_disconnected") def _on_participant_disconnected(participant: rtc.Participant): async def _on_disconnect(): if participant.identity == user_participant.identity: ended_at = datetime.now(timezone.utc) transcript = session.history.to_dict() duration = int(ended_at.timestamp() - started_at.timestamp()) async with SessionLocal() as s: await create_call( s, id=call_id, started_at=started_at, duration_seconds=duration, ended_at=ended_at, recording_key=recording_key, recording_url=get_recording_url(recording_key), transcript=transcript, agent_config_ref=agent_config_ref, ) await stop_recording(egress_id) asyncio.create_task(_on_disconnect()) if name == "__main__": cli.run_app( WorkerOptions( entrypoint_fnc=entrypoint, prewarm_fnc=prewarm, agent_name='signalcore-agent', initialize_process_timeout=120 ) )
t
Thanks so much for sharing your code! From what you’ve described, the issue with aborted retries in Room composite egress might be tied to timing or configuration. Let’s walk through a few steps that could help you debug and fix this: 1. Check Egress Status and Error Fields: Take a look at the
EgressInfo
response, especially fields like
status
,
error
, and
error_code
. These can give clues about why the egress is getting aborted. 2. Verify Room and Participant State: Make sure participants are actively publishing audio tracks before you start the egress. If there’s no content within the timeout, the egress might stop. 3. Analyze Timing: Consider the timing of when you start the egress compared to when participants join and begin publishing. Sometimes adding a small delay before kicking off the egress can make a difference. 4. Review Output Configuration: Double-check that your S3 storage setup — bucket, region, access key, and secret — is all correct and that the storage provider is reachable. 5. Monitor Network Connectivity: If aborts keep happening, it could be network issues or storage outages. Make sure your connection is stable and the storage endpoint is accessible. Also, keeping an eye on the
started_at
,
ended_at
, and
updated_at
timestamps in the
EgressInfo
can really help you understand the egress lifecycle and spot any timing hiccups. If you want, I’m here to help you dive deeper into any of these steps or troubleshoot further. Just let me know! Sources: README.md | Egress & Storage | livekit/livekit_composite | DeepWiki | Infrastructure & Deployment | livekit/livekit_composite | DeepWiki | Webhooks | LiveKit Docs | livekit-protocol/livekit/protocol/egress.pyi
c
How can I get this egress info?
t
Hey there! You can get the
EgressInfo
in a couple of easy ways: 1. Right when you start the egress: The method
start_room_composite_egress
will give you an
EgressInfo
object right away. Here’s a quick example in Python:
Copy code
egress_info = await egress_service.start_room_composite_egress(request)
print(f"Egress ID: {egress_info.egress_id}")
1. After you’ve started the egress: You can call the
ListEgress
method to grab the egress info whenever you need it. For example:
Copy code
list_request = ListEgressRequest(
    egress_id="your-egress-id",  # Optional: if you want info on a specific egress
    room_name="your-room-name",  # Optional: filter by room
    active=True                  # Optional: only show active egresses
)
response = await egress_service.list_egress(list_request)
# response.items will have a list of EgressInfo objects
The
EgressInfo
object includes handy details like
egress_id
,
status
,
error
, and timestamps. If you want, I’m here to help you get this set up in your code! Sources: rpc/egress.pb.go
b
I notice also that it has no destination.
t
It looks like the "no destination" issue in your Room composite egress is happening because the egress request didn’t include a properly set output destination. For Room composite egress, you need to specify at least one output type. Here are the options you can choose from: • File Outputs: To record files like MP4 or OGG. • Stream Outputs: For live streaming using RTMP, SRT, and more. • Segment Outputs: To create HLS segmented files. • Image Outputs: For taking periodic screenshots. To fix this, just make sure your egress request includes at least one valid output setup. For example, if you want to use file outputs, it might look like this:
Copy code
{
  "room_name": "your-room",
  "file_outputs": [
    {
      "file_type": "OGG",
      "filepath": "recording.ogg",
      "s3": {
        "access_key": "your-key",
        "secret": "your-secret",
        "bucket": "your-bucket"
      }
    }
  ]
}
If you’d like, I’m happy to help you go over your egress request or assist with setting up the output destination you need. Just let me know! Sources: livekit-protocol/livekit/protocol/room.pyi | test/edge.go | Egress & Recording | livekit/livekit_composite | DeepWiki
b
Yeah, but I'm not trying to retry the auto recording. It saves it correctly the first time. I'm not sure why it retries with no destination, with a single start a board, and whatever.
t
Hey there! I see you're noticing some retries even though your recording is saving just fine. That can happen because of how the egress system handles retries. Let me walk you through some common reasons and how you might troubleshoot them: 1. Multiple Output Destinations: If you’re sending your recording to a few places (like a file and a stream), one might work while another hits a snag, causing retries. 2. Stream Status: Each stream has its own status (like
ACTIVE
or
FAILED
), so if one stream has an issue, it might trigger retries even if the file recording went through perfectly. 3. Network Issues: Sometimes, spotty connections to storage or streaming endpoints can lead to those retries popping up. 4. Track Disconnection: If someone disconnects during the recording, that might also cause retry behavior. Here are some friendly tips to help you dig a bit deeper: 1. Try using the
ListEgress
API to peek at the status of each output and spot any hiccups. 2. Check out the
stream_results
in your egress info to see if any individual streams are running into trouble. 3. Give your egress setup a quick review to make sure there’s nothing conflicting or causing issues. 4. Make sure your network is stable and that all your output destinations (like S3 or RTMP) are reachable without problems. If you don’t mind sharing a bit more about your egress setup—like what kinds of outputs you’re using and any error messages or status updates you’ve noticed—I’d be happy to help you get to the bottom of those retries! Sources: README.md | livekit-protocol/livekit/protocol/egress.pyi | protobufs/livekit_egress.proto