inference icon indicating copy to clipboard operation
inference copied to clipboard

Realtime gateway can close with 1011 instead of reporting upload validation errors

Open Jackmeson1 opened this issue 3 weeks ago • 0 comments

System Info / 系統信息

Windows 11, Python 3.14.6, aiohttp 3.14.5, Uvicorn 0.54.0, websockets 17.3, Transformers 5.17.0. Reproduced with the real gateway and realtime runtime using the repository's CPU echo model; no model weights are needed.

Running Xinference with Docker? / 是否使用 Docker 运行 Xinfernece?

  • [x] installation from source / 从源码安装
  • [ ] docker / docker

Version info / 版本信息

Source at 0b46522f6439a5004612eeccb6f418ce326137b9.

The command used to start Xinference / 用以启动 xinference 的命令

The standalone reproduction below uses the repository's test helper to start an in-process Uvicorn gateway and a real RealtimeRuntime. Save it as realtime_gateway_repro.py and run python realtime_gateway_repro.py from the checkout with the test dependencies, including websockets, available and PYTHONPATH=..

Reproduction / 复现过程

import asyncio

import aiohttp

from xinference.api.tests.test_realtime_api import serve_gateway
from xinference.core.tests.test_realtime_runtime import CONFIG


async def main():
    async with serve_gateway() as service, aiohttp.ClientSession() as client:
        async with client.ws_connect(service.url) as ws:
            await ws.send_json(CONFIG)
            await ws.receive_json(timeout=2)
            await ws.send_bytes(b"\x00" * 200000)
            message = await ws.receive(timeout=2)
            print(message.type.name, message.data)


asyncio.run(main())

Observed output on the base commit: CLOSE 1011, without an error event. Separate gateway tests sending hello, [1], or {"event": 1} as text after session.started also observed a bare 1011 close. The failure depends on task scheduling.

Expected behavior / 期待表现

doc/source/user_guide/realtime.rst documents a default 64 KiB input-frame limit. The existing gateway and core/realtime/protocol.py define an error event with message_too_large followed by close 1009 for oversized media, or invalid_event followed by close 1008 for malformed control text.

When upload validation raises, the backend context exits before the forwarding tasks are settled. Backend teardown can wake download() and let it close the client before the outer handler sends the intended error event.

AI disclosure: this was prepared with AI assistance (Claude Opus 5.5 and Claude Sonnet 5.5).

Jackmeson1 avatar Nov 10 '26 23:11 Jackmeson1