diff --git a/changelog/3185.fixed.md b/changelog/3185.fixed.md new file mode 100644 index 000000000..2dcdd4728 --- /dev/null +++ b/changelog/3185.fixed.md @@ -0,0 +1,2 @@ +- Fixed an issue that caused `WebsocketService` instances to attempt + reconnection during shutdown. diff --git a/src/pipecat/services/websocket_service.py b/src/pipecat/services/websocket_service.py index d19e6ad4d..1179c4c03 100644 --- a/src/pipecat/services/websocket_service.py +++ b/src/pipecat/services/websocket_service.py @@ -12,7 +12,7 @@ from typing import Awaitable, Callable, Optional import websockets from loguru import logger -from websockets.exceptions import ConnectionClosedOK +from websockets.exceptions import ConnectionClosedError, ConnectionClosedOK from websockets.protocol import State from pipecat.frames.frames import ErrorFrame @@ -137,6 +137,10 @@ class WebsocketService(ABC): # Normal closure, don't retry logger.debug(f"{self} connection closed normally: {e}") break + except ConnectionClosedError as e: + # Error closure, don't retry + logger.warning(f"{self} connection closed, but with an error: {e}") + break except Exception as e: message = f"{self} error receiving messages: {e}" logger.error(message)