[2025-12-09 22:49:23] [ERROR] livekit.agents: fail...
# ask-ai
e
[2025-12-09 224923] [ERROR] livekit.agents: failed to perform clear buffer rpc Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/livekit/agents/voice/avatar/_datastream_io.py", line 174, in _clear_buffer_task await self._room.local_participant.perform_rpc( File "/usr/local/lib/python3.11/site-packages/livekit/rtc/participant.py", line 328, in perform_rpc raise RpcError._from_proto(cb.perform_rpc.error) livekit.rtc.rpc.RpcError: Failed to send [2025-12-09 224923] [ERROR] livekit: livekit:roomparticipantlocal participant786livekitroomparticipant:local_participant - Failed to publish RPC request: engine: connection error: engine is closed is it issue from livekit ??
t
Thanks for reaching out, Guess. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're seeing RPC failures because the local participant tried to send an RPC after the WebRTC engine had already closed — not a LiveKit server outage. Why this happened (brief) • The log shows
perform_rpc
raised
RpcError: Failed to send
and the engine error
engine is closed
. • That means the client-side connection/session was already closing or closed when
_clear_buffer_task
attempted to send the RPC. What you can do now • Cancel or stop background cleanup tasks (like
_clear_buffer_task
) before shutting down the session. • Prevent RPCs after disconnect by checking connection state or listening for the room disconnect event and gating RPC calls. • Wrap
perform_rpc
in try/except to handle
RpcError
and avoid noisy errors during shutdown. Quick code patterns • Cancel tasks on shutdown or on
disconnected
event. • Example RPC error handling:
Copy code
try:
    await participant.perform_rpc(...)
except rpc.RpcError as e:
    logger.warning(f"RPC failed: {e}")
If you want, tell me: • whether this happens every shutdown or only sometimes, • how you trigger room shutdown (manual/timeout/crash), • and the agent lifecycle code around
_clear_buffer_task
. I can then suggest where to add cancellation checks or show a small patch to avoid the race. Sources: Remote method calls | LiveKit docs | client-sdk-js | livekit/livekit_composite | DeepWiki | Connecting to LiveKit | LiveKit docs | Agent speech and audio | LiveKit docs | Virtual avatar plugins | LiveKit Docs