For voice recordings, is there anyway to get info ...
# ask-ai
p
For voice recordings, is there anyway to get info logs? When there are issues with the IAM role (ie. using S3 bucket as a data store), it doesn't show any errors in the console.
t
Thanks for reaching out, Mario. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm here to help you access info logs for voice recordings and troubleshoot any issues with IAM roles and S3 buckets. Here are some helpful methods you can try: • Runtime Logs: LiveKit provides runtime logs specifically for egress services, which manage voice recordings. These logs are great for spotting issues like S3 upload failures caused by IAM misconfigurations. • Enable AWS SDK Logging: You can set the
aws_log_level
in your S3 storage configuration to
LogDebug
or a similar level. This will help capture detailed AWS-related logs, giving you more insight. • S3 Logger: The LiveKit storage module has an
S3Logger
that logs AWS errors during upload failures, such as permission problems. This can be really useful for pinpointing issues. • Forward Logs: Consider forwarding runtime logs to tools like CloudWatch. This way, you can have centralized monitoring and easily correlate logs with AWS events. Also, please double-check that your IAM role has the necessary permissions (like
s3:PutObject
) and is properly attached to the instance or service running LiveKit Egress. If you have any questions or need more help, just let me know—I’m happy to assist! Sources: Log collection | LiveKit Docs | README.md | logging.go
p
Show me how I can enable runtime logs for the egress service, because I couldn't find any errors in the logs
t
Hi there! To help you enable runtime logs for the egress service in LiveKit, here’s a simple step-by-step guide: 1. First, open your egress service configuration file (YAML format) and set the
log_level
field to
debug
. Here’s an example to make it easier:
Copy code
log_level: debug
api_key: your-api-key
api_secret: your-api-secret
ws_url: ws://your-livekit-server-url
redis:
  address: your-redis-address
1. If you’re using Docker, please make sure the configuration file is properly mounted and referenced like this:
Copy code
docker run --rm \
  -e EGRESS_CONFIG_FILE=/out/config.yaml \
  -v ~/egress-test:/out \
  livekit/egress
1. And if you’re deploying with Helm, just set the log level in your
values.yaml
file like so:
Copy code
egress:
  log_level: debug
After setting this up, your egress service will start generating detailed logs, including GStreamer debugging at level 3. If you have any questions or need a hand with any of these steps, feel free to reach out—I’m here to help! Sources: README.md
p
Um... this is how I'm doing it:
Copy code
req = api.RoomCompositeEgressRequest(
        room_name=ctx.room.name,
        audio_only=True,
        file_outputs=[
            api.EncodedFileOutput(
                file_type=api.EncodedFileType.OGG,
                filepath=f"{file_root_name}.ogg",
                s3=recording_storage,
            )
        ],
    )
t
To help you enable runtime logs for operations like
RoomCompositeEgressRequest
, you'll want to set up log forwarding for the LiveKit service itself. Here are some options you can choose from: • Sentry: Simply add a
SENTRY_DSN
as a secret to your LiveKit Cloud project to forward logs to Sentry. • Datadog: You can add a
DATADOG_TOKEN
(and optionally
DATADOG_REGION
) as a secret to forward logs to Datadog. • CloudWatch: By adding
AWS_ACCESS_KEY_ID
and
AWS_SECRET_ACCESS_KEY
as secrets, and optionally setting
AWS_REGION
, you can integrate with CloudWatch. • New Relic: Just add a New Relic key as a secret to enable log forwarding. These logs will give you detailed runtime information about the egress process, including transcoding and S3 upload activities. If you prefer, you can also use the LiveKit CLI to follow runtime logs in real time from the latest agent instance. Please feel free to reach out if you'd like a hand setting up any of these options — I'm here to help! Sources: Log collection | LiveKit Docs | Universal Egress
p
Um... I'd like to capture any errors with recordings as a callback, so that I can handle it from my agent.
t
I’m here to help you capture errors with recordings as a callback! Depending on your setup, here are some approaches you can try: • CaptureAudioFrameCallback: This callback lets you receive error notifications during audio frame capture. For instance, in the Unity SDK:
Copy code
var asyncId = res.CaptureAudioFrame.AsyncId;
void Callback(CaptureAudioFrameCallback callback)
{
    if (callback.AsyncId != asyncId) return;
    if (callback.HasError)
        Utils.Error($"Audio capture failed: {callback.Error}");
    FfiClient.Instance.CaptureAudioFrameReceived -= Callback;
}
FfiClient.Instance.CaptureAudioFrameReceived += Callback;
• MediaRecorder Error Events: If you're working with browser-based recording, you can listen to the
error
event on the
MediaRecorder
object to catch any recording errors. • AI Agent Error Handling: When using LiveKit Agents, try listening for the
error
event on the
AgentSession
object to manage both recoverable and unrecoverable errors. Please let me know which setup you’re using, and I’d be happy to offer more personalized guidance to get you sorted out! Sources: packages/livekit-rtc/src/proto/room_pb.ts | Runtime/Scripts/RtcAudioSource.cs | src/room/track/record.ts | Events and error handling | LiveKit Docs | livekit-ffi/src/server/audio_source.rs
p
I'm using Python.
t
In the Python SDK, you can gently handle recording errors with a few helpful approaches: • AgentSession Error Handling: You can use the
AgentSession.on("error", callback)
method to catch errors related to STT, TTS, and other agent functions. Here’s a simple example to guide you:
Copy code
async def handle_error(event):
    error = event.error
    print(f"Error: {error}")
    if not error.recoverable:
        await event.source.say("An unrecoverable error occurred.")

session.on("error", handle_error)
• Egress API Error Handling: When dealing with room recordings, it’s a good idea to manage errors right at the API call using try/catch blocks, like this:
Copy code
try:
    egress_info = await lkapi.egress.start_room_composite_egress(req)
    print("Recording started:", egress_info.egress_id)
except Exception as e:
    print("Failed to start recording:", str(e))
• Monitor Egress Status: It’s also helpful to keep an eye on the egress status by polling, so you can spot any issues during recording:
Copy code
status = await lkapi.egress.list_egress(room_name="your-room")
for egress in status:
    if egress.status == "failed":
        print(f"Recording failed: {egress.error}")
If you’d like, I’m here to help you implement any of these methods or answer any questions you have along the way! Sources: Events and error handling | LiveKit Docs | agent/main.py | Runtime/Scripts/RtcAudioSource.cs | livekit-rtc/livekit/rtc/_proto/ffi_pb2.pyi
p
If I don't implement on error, is it still going to be thrown in logs? Or I must implement it?
t
Absolutely, errors are automatically logged in the LiveKit Python SDK even if you haven't set up an error callback. The SDK thoughtfully uses Python's standard logging module to catch and log errors from both the native FFI layer and the higher-level components. You'll find these logs in your application's usual logging output, unless you've adjusted the logging settings to hide them. If you'd like, I'm here to help you configure or access these logs—just let me know! Sources: livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/real... | terminal-client/client.py | stream_audio.py | livekit-rtc/livekit/rtc/_ffi_client.py
p
So, they are not. Not for room recording. Let's do this: tell me what error will be thrown for the recording, if it doesn't have access to upload to an s3 bucket.
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!