HKUDS/nanobot · error · ConnectionError

SSE connection failed with status

Error message

SSE connection failed with status {response.status_code}

What it means

Raised in SignalChannel._sse_receive_loop: the HTTP-mode long-poll GET to /api/v1/events returned a non-200 status, so the SSE event stream could not be established. Raised as ConnectionError; typically means signal-cli is down, misconfigured, or the token is invalid.

Solutions

  1. Check signal-cli daemon logs for why the SSE endpoint rejects the request (auth, wrong path, version mismatch)
  2. Confirm daemon_host/daemon_port configuration matches the signal-cli-rest-api deployment
  3. Let the reconnect loop retry after daemon issues are fixed
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at nanobot/channels/signal/runtime.py:615 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/nanobot@42f37dc4c0 (2026-08-26). Data as JSON: /api/errors/7b5278dfeea94305. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/channels/signal/runtime.py:615

            raise
        finally:
            # Keep typing active across progress updates; stop on the final reply.
            if not is_progress_message:
                # Avoid immediate START->STOP for fast responses, which can be invisible
                # in some Signal clients. Let indicator expire naturally (~15s).
                await self._stop_typing(msg.chat_id, send_stop=False)

    async def _sse_receive_loop(self) -> None:
        """Receive messages via Server-Sent Events (HTTP mode)."""
        if not self._http:
            raise RuntimeError("HTTP client not initialized for Signal SSE stream")

        self.logger.info("Started Signal message receive loop (SSE)")

        try:
            async with self._http.stream("GET", "/api/v1/events") as response:
                if response.status_code != 200:
                    raise ConnectionError(
                        f"SSE connection failed with status {response.status_code}"
                    )

                self.logger.info("Subscribed to Signal messages via SSE")

                # Buffer for accumulating SSE data across multiple lines
                event_buffer: list[str] = []

                async for line in response.aiter_lines():
                    if not self._running:
                        break

                    # Debug: log raw SSE lines (except keepalive pings)
                    if line and line != ":":
                        self.logger.debug("SSE line received: {}", line[:200])

                    # SSE format handling
                    if isinstance(line, str):  # pyright: ignore[reportUnnecessaryIsInstance]

View on GitHub (pinned to 42f37dc4c0)