async def _receive_task_handler(self, report_error: Callable[[ErrorFrame], Awaitable[None]]):
        """Handles WebSocket message receiving with automatic retry logic.

        Args:
            report_error: Callback to report errors
        """
        retry_count = 0
        MAX_RETRIES = 3

        while True:
            try:
                await self._receive_messages()
                retry_count = 0  # Reset counter on successful message receive
                if self._websocket and self._websocket.state == State.CLOSED:
                    raise websockets.ConnectionClosedOK(
                        self._websocket.close_rcvd,
                        self._websocket.close_sent,
                        self._websocket.close_rcvd_then_sent,
                    )
            except Exception as e:
                message = f"{self} error receiving messages: {e}"
                logger.error(message)

                if self._reconnect_on_error:
                    retry_count += 1
                    if retry_count >= MAX_RETRIES:
                        await report_error(ErrorFrame(message, fatal=True))
                        break

                    logger.warning(f"{self} connection error, will retry: {e}")
                    await report_error(ErrorFrame(message))

                    try:
                        if await self._reconnect_websocket(retry_count):
                            retry_count = 0  # Reset counter on successful reconnection
                        wait_time = exponential_backoff_time(retry_count)
                        await asyncio.sleep(wait_time)
                    except Exception as reconnect_error:
                        logger.error(f"{self} reconnection failed: {reconnect_error}")
                else:
                    await report_error(ErrorFrame(message))
                    break
Handles WebSocket message receiving with automatic retry logic.

        Args:
            report_error: Callback to report errors
        
src/pipecat/services/websocket_service.py