You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AIOHTTP启用SSL后出现ConnectionResetError错误求助

AIOHTTP HTTPS服务器持续出现ConnectionResetError (WinError 10054)错误

我参考AIOHTTP官方文档和Stack Overflow相关回答搭建了一个简单的AIOHTTP HTTPS服务器,代码如下:

async def handle(request):
    name = request.match_info.get('name', "Anonymous")
    text = "Hello, " + name
    print(text)
    return web.Response(text=text)


app = web.Application()
app.add_routes([web.get('/', handle),
                web.get('/{name}', handle)])
ssl_context: SSLContext = create_default_context(purpose=Purpose.CLIENT_AUTH)
ssl_context.load_cert_chain(certfile=<my cert file>)

if __name__ == '__main__':
    web.run_app(app, ssl_context=ssl_context)

服务器运行一段时间后,持续触发以下错误:

Exception in callback _ProactorBasePipeTransport._call_connection_lost(None)
handle: <Handle _ProactorBasePipeTransport._call_connection_lost(None)>
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "C:\Program Files\Python310\lib\asyncio\proactor_events.py", line 162, in _call_connection_lost
    self._sock.shutdown(socket.SHUT_RDWR)
ConnectionResetError: [WinError 10054] Une connexion existante a dû être fermée par l’hôte distant

注意:不启用SSL时服务器无此错误,且所有功能运行正常,日志输出示例:

======== Running on https://0.0.0.0:8443 ========
(Press CTRL+C to quit)
Hello, Anonymous
Hello, favicon.ico

恳请各位提供相关解决思路,谢谢。

内容的提问来源于stack exchange,提问作者Kerberos

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 18:45:41