LocalProtocolError( h11._util.LocalProtocolError:当角色 = SERVER 且状态 = MUST_CLOSE 时无法处理事件类型响应

Sem*_*sky 5 python streaming fastapi

我有以下问题:我有一个 Ubuntu 20.04.1,在 Docker 容器中我有 Python 应用程序,使用 FastAPI 接受来自 Appsflyer 的数据流(POST 方法)。库版本有:

fastapi~=0.78.0
uvicorn~=0.17.6
pydantic~=1.9.1
aio_pika~=8.0.3
Run Code Online (Sandbox Code Playgroud)

每隔 10-12 小时,我就会出现以下错误: LocalProtocolError( h11._util.LocalProtocolError: can't handle event type Response when role=SERVER and state=MUST_CLOSE ,因此我会丢失数据。其根本原因可能是什么? 谢谢

小智 -1

尝试检查响应期间是否存在未处理的异常。可能的变体之一是服务器重新启动或 uvicorn 出现其他一些问题。

该线程可能会帮助您 https://github.com/encode/httpx/issues/96