broad-lamp-30178
09/12/2025, 11:02 PM{"message": "websocket closed unexpectedly", "level": "WARNING", "name": "livekit.plugins.elevenlabs",
how to recover agent from this?tall-airline-16756
09/12/2025, 11:02 PMtall-airline-16756
09/12/2025, 11:03 PMlivekit.plugins.elevenlabs
plugin. This message means that the WebSocket connection to the ElevenLabs TTS service was closed unexpectedly. Since the Python SDK doesn't automatically handle this, you'll want to add some custom retry logic in your application to keep things running smoothly.
Here are a few friendly steps to help you recover from this:
• Catch exceptions like APIConnectionError
when the WebSocket closes unexpectedly.
• Try using an exponential backoff strategy to space out your reconnection attempts—this helps avoid overwhelming the service.
• When reconnecting, create a new WebSocket connection to re-instantiate the TTS stream.
Also, you might find the FallbackAdapter
from LiveKit really useful! It lets you set up a fallback TTS provider that automatically switches if the primary ElevenLabs service runs into trouble.
If you'd like, I’m happy to provide a code example or walk you through implementing this. Just let me know—I’m here to help!
Sources: livekit-plugins/livekit-plugins-deepgram/livekit/plugins/deepgram/stt.py | plugins/elevenlabs/src/tts.ts | Events and error handling | LiveKit Docs