diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c590528d..fc34046d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed an `RTVI` issue that was causing `bot-tts-text` messages to be sent before being processed by the output transport. +- Fixed an issue[#1192] in 11labs where we are trying to reconnect/disconnect the + websocket connection even when the connection is already closed. + ## [0.0.56] - 2025-02-06 ### Changed diff --git a/src/pipecat/services/elevenlabs.py b/src/pipecat/services/elevenlabs.py index b479759ae..e0b985411 100644 --- a/src/pipecat/services/elevenlabs.py +++ b/src/pipecat/services/elevenlabs.py @@ -388,7 +388,11 @@ class ElevenLabsTTSService(WordTTSService, WebsocketService): async def _keepalive_task_handler(self): while True: await asyncio.sleep(10) - await self._send_text("") + try: + await self._send_text("") + except websockets.ConnectionClosed as e: + logger.warning(f"{self} keepalive error: {e}") + break async def _send_text(self, text: str): if self._websocket: diff --git a/src/pipecat/services/websocket_service.py b/src/pipecat/services/websocket_service.py index 7e480f2b7..9c942b019 100644 --- a/src/pipecat/services/websocket_service.py +++ b/src/pipecat/services/websocket_service.py @@ -85,6 +85,9 @@ class WebsocketService(ABC): await self._receive_messages() logger.debug(f"{self} connection established successfully") retry_count = 0 # Reset counter on successful message receive + except websockets.ConnectionClosed as e: + logger.warning(f"{self} connection closed: {e}") + break except Exception as e: retry_count += 1 if retry_count >= MAX_RETRIES: