I am testing a simple AIOHTTP server inspired by this documentation and this answer:
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)
and I keep getting this error after a while:
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
The error doesn't appear when I do not use SSL.
Note that everything else seems to work fine:
======== Running on https://0.0.0.0:8443 ========
(Press CTRL+C to quit)
Hello, Anonymous
Hello, favicon.ico
Any insight would be much appreciated, thanks.