fixing disconnect issue

This commit is contained in:
Vaibhav159
2025-02-10 22:55:20 +05:30
parent 081abcedb3
commit b06b16adb7
3 changed files with 11 additions and 1 deletions

View File

@@ -42,6 +42,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
`RTVIBotLLMProcessor`) are now deprecated, instantiate an `RTVIObserver`
instead.
### Fixed
- 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

View File

@@ -388,7 +388,10 @@ 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}")
async def _send_text(self, text: str):
if self._websocket:

View File

@@ -85,6 +85,8 @@ 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}")
except Exception as e:
retry_count += 1
if retry_count >= MAX_RETRIES: