hypercorn
hypercorn copied to clipboard
SSL: APPLICATION_DATA_AFTER_CLOSE_NOTIFY
This seems to be a bug with asyncio... I have done some searching on this issue and it seems like an old bug that should be fixed. I have not made many changes to my quart app, but this problem is suddenly happening. When this error occurs the backend closes requests from the frontend until new requests are made.
Some information that may be useful is... the screens of my frontend which are creating this error in the backend are sending multiple async api calls to quart at the same time... I have disabled all requests except 1 request per screen and the backend stopped closing requests and the frontend stopped hanging. I do not really have a need for async backend currently, so considering going to Flask if this is an async issue with the backend, but wanted to report this bug to the dev team here at quart.
Traceback:
Task exception was never retrieved
future: <Task finished name='Task-2685' coro=<worker_serve.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/hypercorn/asyncio/tcp_server.py", line 56, in run async with TaskGroup(self.loop) as task_group: File "/usr/local/lib/python3.10/site-packages/hypercorn/asyncio/task_group.py", line 75, in aexit await task asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/hypercorn/asyncio/run.py", line 96, in _server_callback
await TCPServer(app, loop, config, context, reader, writer)
File "/usr/local/lib/python3.10/site-packages/hypercorn/asyncio/tcp_server.py", line 74, in run
await self._close()
File "/usr/local/lib/python3.10/site-packages/hypercorn/asyncio/tcp_server.py", line 117, in _close
await self.writer.wait_closed()
File "/usr/local/lib/python3.10/asyncio/streams.py", line 344, in wait_closed
await self._protocol._get_close_waiter(self)
File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 534, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 206, in feed_ssldata
self._sslobj.unwrap()
File "/usr/local/lib/python3.10/ssl.py", line 979, in unwrap
return self._sslobj.shutdown()
ssl.SSLError: [SSL: APPLICATION_DATA_AFTER_CLOSE_NOTIFY] application data after close notify (_ssl.c:2672)
[2022-08-29 20:58:07 +0000] [1] [INFO] 99.7.90.52:57862 GET /users/users 2 200 353 3331
Task exception was never retrieved
future: <Task finished name='Task-2696' coro=<worker_serve.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/hypercorn/asyncio/tcp_server.py", line 56, in run async with TaskGroup(self.loop) as task_group: File "/usr/local/lib/python3.10/site-packages/hypercorn/asyncio/task_group.py", line 75, in aexit await task asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/hypercorn/asyncio/run.py", line 96, in _server_callback await TCPServer(app, loop, config, context, reader, writer) File "/usr/local/lib/python3.10/site-packages/hypercorn/asyncio/tcp_server.py", line 74, in run await self._close() File "/usr/local/lib/python3.10/site-packages/hypercorn/asyncio/tcp_server.py", line 117, in _close await self.writer.wait_closed() File "/usr/local/lib/python3.10/asyncio/streams.py", line 344, in wait_closed await self._protocol._get_close_waiter(self) File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 534, in data_received ssldata, appdata = self._sslpipe.feed_ssldata(data) File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 206, in feed_ssldata self._sslobj.unwrap() File "/usr/local/lib/python3.10/ssl.py", line 979, in unwrap return self._sslobj.shutdown() ssl.SSLError: [SSL: APPLICATION_DATA_AFTER_CLOSE_NOTIFY] application data after close notify (_ssl.c:2672)
requirements.txt
quart==0.18.0 APScheduler==3.8.1 Quart-CORS==0.5.0 paho-mqtt==1.6.1 flask-marshmallow==0.14.0 pexpect==4.8.0 marshmallow-sqlalchemy==0.26.1 requests==2.25.1 jsonschema==4.3.2 pymongo Jinja2==3.0.3 bcrypt pyjwt
Dockerfile
FROM python:3.10.6-slim-buster
WORKDIR /app
COPY requirements.txt requirements.txt
RUN apt-get update RUN apt-get -y install gcc RUN apt-get install -y awscli sshpass netcat-openbsd wget build-essential libffi-dev python-dev
RUN pip3 install -r requirements.txt
COPY . .
COPY etc/hosts /etc/beta_app/ COPY deployments /etc/beta_app
CMD ["python3", "app.py"]
Environment:
- Python version: Tested on 3.8-slim-buster, 3.9-slim-buster, and 3.10.6-slim-buster (docker images)
- Quart version: 0.18.0
Any update here?
I also have this issue with my FastAPI app over https.
Having the same issue. Looking at that file, is it possible to just add SSLError to the errors being handled on this line?
https://github.com/pgjones/hypercorn/blob/d7990fb4b07a9b87390f60dcb1647789f99cdcc6/src/hypercorn/asyncio/tcp_server.py#L118
I'm not exceptionally experienced with SSL, but my guess is that some sort of request is being passed to/from the application, to a socket which is already closed, so we can just assume that the connection has been closed at the point where this error happens?
I think this is fixed, please open a new issue if not
The error has not been fixed. On version 0.17.3 the exact same error occurs.