HKUDS/nanobot · error · RuntimeError

Slack Socket Mode WebSocket connect timed out

Error message

Slack Socket Mode WebSocket connect timed out

What it means

Timeout in Slack start(): the Socket Mode client's WebSocket handshake exceeded SLACK_SOCKET_CONNECT_TIMEOUT_S. Notably, auth_test over HTTPS may have succeeded, so this specifically indicates the WSS connection to Slack's websocket endpoint is blocked or slow — a common proxy/firewall symptom.

Solutions

  1. Allow outbound WebSocket (wss://) traffic to Slack endpoints in the proxy/firewall
  2. Configure HTTPS_PROXY/HTTP_PROXY so the socket client can traverse the proxy
  3. Retry once network egress for WebSockets is confirmed (e.g. with a wss echo test)
Defensive patterns

Strategy: retry

When it happens

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

Common situations: See trigger scenarios.

Understand the failure class


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

Appendix: source

Thrown at nanobot/channels/slack/runtime.py:179

        except Exception as e:
            self.logger.warning("auth_test failed: {}", e)

        self.logger.info("Starting Socket Mode client...")
        try:
            await asyncio.wait_for(
                self._socket_client.connect(),
                timeout=SLACK_SOCKET_CONNECT_TIMEOUT_S,
            )
        except asyncio.TimeoutError:
            self.logger.error(
                "Slack Socket Mode WebSocket handshake timed out after {:.0f}s. "
                "auth_test uses HTTPS and may still succeed while WSS is blocked. "
                "Check outbound access to Slack WebSockets; slack-sdk Socket Mode "
                "does not apply HTTP(S)_PROXY to websockets.connect.",
                SLACK_SOCKET_CONNECT_TIMEOUT_S,
            )
            await self.stop()
            raise RuntimeError("Slack Socket Mode WebSocket connect timed out") from None

        self.logger.info("Slack Socket Mode WebSocket connected (events enabled)")

        while self._running:
            await asyncio.sleep(1)

    async def stop(self) -> None:
        """Stop the Slack client."""
        self._running = False
        if self._socket_client:
            try:
                await self._socket_client.close()
            except Exception as e:
                self.logger.warning("socket close failed: {}", e)
            self._socket_client = None

    async def send(self, msg: OutboundMessage) -> None:
        """Send a message through Slack."""

View on GitHub (pinned to 42f37dc4c0)