diff --git a/src/gateway/voiceclaw-realtime/upgrade.test.ts b/src/gateway/voiceclaw-realtime/upgrade.test.ts index b32bec7b469..5da10c23fa9 100644 --- a/src/gateway/voiceclaw-realtime/upgrade.test.ts +++ b/src/gateway/voiceclaw-realtime/upgrade.test.ts @@ -1,11 +1,13 @@ import { afterEach, describe, expect, it } from "vitest"; import { type RawData, WebSocket, WebSocketServer } from "ws"; import type { ResolvedGatewayAuth } from "../auth.js"; +import { MAX_PAYLOAD_BYTES } from "../server-constants.js"; import { attachGatewayUpgradeHandler, createGatewayHttpServer } from "../server-http.js"; import { createPreauthConnectionBudget } from "../server/preauth-connection-budget.js"; import type { GatewayWsClient } from "../server/ws-types.js"; import { withTempConfig } from "../test-temp-config.js"; import { VOICECLAW_REALTIME_PATH } from "./paths.js"; +import { VOICECLAW_REALTIME_MAX_PAYLOAD_BYTES } from "./upgrade.js"; const previousGeminiApiKey = process.env.GEMINI_API_KEY; const previousTestHandshakeTimeout = process.env.OPENCLAW_TEST_HANDSHAKE_TIMEOUT_MS; @@ -24,6 +26,10 @@ afterEach(() => { }); describe("VoiceClaw realtime gateway upgrade", () => { + it("keeps the realtime websocket payload cap aligned with gateway clients", () => { + expect(VOICECLAW_REALTIME_MAX_PAYLOAD_BYTES).toBe(MAX_PAYLOAD_BYTES); + }); + it("accepts the realtime path without the generic gateway websocket handler", async () => { delete process.env.GEMINI_API_KEY; await withRealtimeGateway(async ({ port }) => { diff --git a/src/gateway/voiceclaw-realtime/upgrade.ts b/src/gateway/voiceclaw-realtime/upgrade.ts index cc173280cd5..0f175eeb443 100644 --- a/src/gateway/voiceclaw-realtime/upgrade.ts +++ b/src/gateway/voiceclaw-realtime/upgrade.ts @@ -4,12 +4,18 @@ import { WebSocketServer } from "ws"; import type { OpenClawConfig } from "../../config/types.openclaw.js"; import type { AuthRateLimiter } from "../auth-rate-limit.js"; import type { ResolvedGatewayAuth } from "../auth.js"; +import { MAX_PAYLOAD_BYTES } from "../server-constants.js"; import { VOICECLAW_REALTIME_PATH } from "./paths.js"; import { VoiceClawRealtimeSession } from "./session.js"; export { VOICECLAW_REALTIME_PATH }; -const wss = new WebSocketServer({ noServer: true }); +export const VOICECLAW_REALTIME_MAX_PAYLOAD_BYTES = MAX_PAYLOAD_BYTES; + +const wss = new WebSocketServer({ + noServer: true, + maxPayload: VOICECLAW_REALTIME_MAX_PAYLOAD_BYTES, +}); export function handleVoiceClawRealtimeUpgrade(opts: { req: IncomingMessage;