diegosouzapw/OmniRoute · error

UNAUTHORIZED

UNAUTHORIZED

Error message

${auth.error || "Unauthorized"}

What it means

WebSocket authorization: authorizeConnection returned a failure, so the server sends an error frame carrying auth.error (or the default 'Unauthorized') and closes the socket. The Bearer token from the upgrade request was missing, expired, or invalid.

Solutions

  1. Re-authenticate and reconnect with a fresh Bearer token
  2. Check the auth.error detail in the error frame for the specific cause
  3. Ensure the client attaches the Authorization header on the WS upgrade
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/server/ws/liveServer.ts:532 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/0aa8d3d134ddd529. Report an issue: GitHub.

Appendix: source

Thrown at src/server/ws/liveServer.ts:532

    const origin = request.headers["origin"];
    const originStr = Array.isArray(origin) ? origin[0] : origin;
    if (!isOriginAllowed(originStr)) {
      sendTo(ws, { type: "error", code: "FORBIDDEN_ORIGIN", message: "Origin not allowed" });
      ws.close(4003, "Forbidden origin");
      return;
    }

    // Enforce max clients
    if (clients.size >= MAX_CLIENTS) {
      sendTo(ws, { type: "error", code: "SERVER_FULL", message: "Max clients reached" });
      ws.close(1013, "Server full");
      return;
    }

    // Authorize
    const auth = await authorizeConnection(request);
    if (!auth.authorized) {
      sendTo(ws, { type: "error", code: "UNAUTHORIZED", message: auth.error || "Unauthorized" });
      ws.close(4001, "Unauthorized");
      return;
    }

    const clientId = auth.sessionId;
    activeClientId = clientId;
    const client: ClientState = {
      ws,
      sessionId: clientId,
      subscribedChannels: new Set(),
      lastActivity: Date.now(),
      eventCounter: 0,
      eventCounterReset: Date.now(),
      remoteAddress: request.socket?.remoteAddress || "unknown",
    };

    clients.set(clientId, client);

View on GitHub (pinned to a179ffed5b)