ruvnet/ruflo · error

1013

1013

Error message

Server at capacity

What it means

setupWebSocketHandlers()'s connection callback found the live client count already at config.maxConnections, so the new socket is immediately closed with code 1013 ('try again later') instead of being admitted. This is capacity shedding, not a crash: clients should wait and reconnect when a slot frees.

Source

Thrown at v3/mcp/transport/websocket.ts:288

    try {
      client.ws.close(1000, reason);
      return true;
    } catch {
      return false;
    }
  }

  /**
   * Setup WebSocket handlers
   */
  private setupWebSocketHandlers(): void {
    if (!this.wss) return;

    this.wss.on('connection', (ws, req) => {
      // Check max connections
      if (this.config.maxConnections && this.clients.size >= this.config.maxConnections) {
        this.logger.warn('Max connections reached, rejecting client');
        ws.close(1013, 'Server at capacity');
        return;
      }

      const clientId = `client-${++this.connectionCounter}`;
      const client: ClientConnection = {
        id: clientId,
        ws,
        createdAt: new Date(),
        lastActivity: new Date(),
        messageCount: 0,
        isAlive: true,
        isAuthenticated: !this.config.auth?.enabled,
      };

      this.clients.set(clientId, client);
      this.totalConnections++;

      this.logger.info('Client connected', {

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Increase maxConnections if the limit is too low for expected load.
  2. Ensure disconnected clients are reaped so slots are freed (check heartbeat/cleanup logic).
  3. Have clients implement retry-with-backoff when the server reports capacity.
Defensive patterns

Strategy: validation

When it happens

Trigger: New WebSocket connection arrives while the server is at its configured max-connections cap; connection is refused to protect memory/FD headroom.

Common situations: See trigger scenarios.


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/7a96561bea4bcb2e. Report an issue: GitHub.