Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion livekit-agents/livekit/agents/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,7 @@ async def _connection_task(self) -> None:
assert self._http_session is not None

retry_count = 0
had_successful_connection = False
ws: aiohttp.ClientWebSocketResponse | None = None
while not self._closed:
try:
Expand Down Expand Up @@ -1116,6 +1117,7 @@ async def _connection_task(self) -> None:

self._handle_register(msg.register)
self._connecting = False
had_successful_connection = True

# report all active jobs to the server after registration
await self._report_active_jobs()
Expand All @@ -1134,7 +1136,22 @@ async def _connection_task(self) -> None:
retry_delay = min(retry_count * 2, 10)
retry_count += 1

logger.warning(
# The first reconnect after a successful connection runs at
# delay=0 and almost always succeeds — it's expected churn for
# control-plane websocket lifecycle and produces a steady
# trickle of self-healing WARNINGs that trip warning-level
# alerting with nothing actionable behind them. Only the
# post-success delay=0 case is downgraded; the *very first*
# connection attempt (e.g. wrong URL, auth misconfig) still
# logs at WARNING so boot-time failures stay visible to
# operators relying on WARNING-level aggregation.
is_post_success_first_retry = (
had_successful_connection and retry_delay == 0
)
log_fn = (
logger.info if is_post_success_first_retry else logger.warning
)
log_fn(
f"failed to connect to livekit, retrying in {retry_delay}s",
extra={"retry_count": retry_count, "max_retry": self._max_retry, "error": e},
)
Expand Down
Loading