HKUDS/Vibe-Trading · critical · RuntimeError

Slack Socket Mode WebSocket connect timed out

Error message

Slack Socket Mode WebSocket connect timed out

What it means

Slack Socket Mode client's WebSocket connection did not complete within SLACK_SOCKET_CONNECT_TIMEOUT_S; auth_test over HTTPS can succeed while WSS is blocked.

Source

Thrown at agent/src/channels/slack.py:134

        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 80ffdda44c)

Solutions

  1. Open outbound access to Slack WebSocket endpoints (wss-primary.slack.com:443)
  2. If a proxy is mandatory, route WSS through it explicitly (e.g. python-socks/websockets proxy support) since slack-sdk won't use HTTP(S)_PROXY
  3. Verify with a manual wss connection test from the same host
Defensive patterns

Strategy: fallback

Validate before calling

import socket
socket.create_connection(('wss-primary.slack.com', 443), timeout=5).close()

Try / catch

try:
    await slack.start()
except RuntimeError as e:
    if 'WebSocket connect timed out' in str(e):
        switch_to_alternate_transport_or_alert_ops()

Prevention

When it happens

Trigger: start() when outbound WebSocket traffic to wss://wss-primary.slack.com is blocked by a firewall/proxy; the HTTP-level connection test passed but the socket-mode handshake timed out.

Common situations: Corporate proxies that allow HTTPS but not WSS; slack-sdk's websockets.connect ignores HTTP(S)_PROXY env vars.

Understand the failure class

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/57404b6944f009a3. Report an issue: GitHub.