websocket_service
Base websocket service with automatic reconnection and error handling.
- class pipecat.services.websocket_service.WebsocketService(*, reconnect_on_error: bool = True, **kwargs)[source]
Bases:
ABCBase class for websocket-based services with automatic reconnection.
Provides websocket connection management, automatic reconnection with exponential backoff, connection verification, and error handling. Subclasses implement service-specific connection and message handling logic.
- __init__(*, reconnect_on_error: bool = True, **kwargs)[source]
Initialize the websocket service.
- Parameters:
reconnect_on_error – Whether to automatically reconnect on connection errors.
**kwargs – Additional arguments (unused, for compatibility).
- async send_with_retry(message, report_error: Callable[[ErrorFrame], Awaitable[None]])[source]
Attempt to send a message, retrying after reconnect if necessary.