Closed estyrke closed 1 month ago
I tried with uvicorn too, there I get a 403 response: INFO: ('127.0.0.1', 49425) - "WebSocket /" 403
It seems it has special handling when it gets "websocket.close" when the handshake is not completed.
I should add that our application doesn't use websockets at all, and we have no code to handle websocket requests. We just noticed this crash, probably from some botnet trying to probe us.
@estyrke thank you for reporting thing. Gonna push a fix ASAP and include it in 1.6.1
2024-10-13 18:02:37.467 | RuntimeError: ASGI flow error |
-- | -- | --
| | 2024-10-13 18:02:37.467 | ^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:37.467 | result = task.result() |
| | 2024-10-13 18:02:37.467 | File "/usr/local/lib/python3.12/site-packages/channels/utils.py", line 49, in await_many_dispatch |
| | 2024-10-13 18:02:37.467 | await task |
| | 2024-10-13 18:02:37.467 | File "/usr/local/lib/python3.12/site-packages/channels/utils.py", line 57, in await_many_dispatch |
| | 2024-10-13 18:02:37.467 | await await_many_dispatch( |
| | 2024-10-13 18:02:37.467 | File "/usr/local/lib/python3.12/site-packages/channels/consumer.py", line 58, in __call__ |
| | 2024-10-13 18:02:37.467 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:37.467 | return await consumer(scope, receive, send) |
| | 2024-10-13 18:02:37.467 | File "/usr/local/lib/python3.12/site-packages/channels/consumer.py", line 94, in app |
| | 2024-10-13 18:02:37.467 | ^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:37.467 | return await application( |
| | 2024-10-13 18:02:37.467 | File "/usr/local/lib/python3.12/site-packages/channels/routing.py", line 132, in __call__ |
| | 2024-10-13 18:02:37.467 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:37.467 | return await self.inner(scope, receive, send) |
| | 2024-10-13 18:02:37.467 | File "/usr/local/lib/python3.12/site-packages/channels/middleware.py", line 24, in __call__ |
| | 2024-10-13 18:02:37.467 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:37.467 | return await super().__call__(scope, receive, send) |
| | 2024-10-13 18:02:37.467 | File "/usr/local/lib/python3.12/site-packages/channels/auth.py", line 185, in __call__ |
| | 2024-10-13 18:02:37.467 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:37.467 | return await self.inner(wrapper.scope, receive, wrapper.send) |
| | 2024-10-13 18:02:37.467 | File "/usr/local/lib/python3.12/site-packages/channels/sessions.py", line 263, in __call__ |
| | 2024-10-13 18:02:37.467 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:37.467 | return await self.inner(dict(scope, cookies=cookies), receive, send) |
| | 2024-10-13 18:02:37.467 | File "/usr/local/lib/python3.12/site-packages/channels/sessions.py", line 47, in __call__ |
| | 2024-10-13 18:02:37.467 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:37.467 | return await self.application(scope, receive, send) |
| | 2024-10-13 18:02:37.467 | File "/usr/local/lib/python3.12/site-packages/channels/security/websocket.py", line 37, in __call__ |
| | 2024-10-13 18:02:37.467 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:37.467 | return await application(scope, receive, send) |
| | 2024-10-13 18:02:37.467 | File "/usr/local/lib/python3.12/site-packages/channels/routing.py", line 62, in __call__ |
| | 2024-10-13 18:02:37.467 | await inner(watcher.scope, watcher.proto) |
| | 2024-10-13 18:02:37.467 | File "/usr/local/lib/python3.12/site-packages/granian/_futures.py", line 4, in future_watcher |
| | 2024-10-13 18:02:37.467 | Traceback (most recent call last): |
| | 2024-10-13 18:02:37.467 | [ERROR] Application callable raised an exception |
| | 2024-10-13 18:02:23.466 | RuntimeError: ASGI flow error |
| | 2024-10-13 18:02:23.466 | ^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:23.466 | result = task.result() |
| | 2024-10-13 18:02:23.466 | File "/usr/local/lib/python3.12/site-packages/channels/utils.py", line 49, in await_many_dispatch |
| | 2024-10-13 18:02:23.466 | await task |
| | 2024-10-13 18:02:23.466 | File "/usr/local/lib/python3.12/site-packages/channels/utils.py", line 57, in await_many_dispatch |
| | 2024-10-13 18:02:23.466 | await await_many_dispatch( |
| | 2024-10-13 18:02:23.466 | File "/usr/local/lib/python3.12/site-packages/channels/consumer.py", line 58, in __call__ |
| | 2024-10-13 18:02:23.466 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:23.466 | return await consumer(scope, receive, send) |
| | 2024-10-13 18:02:23.466 | File "/usr/local/lib/python3.12/site-packages/channels/consumer.py", line 94, in app |
| | 2024-10-13 18:02:23.466 | ^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:23.466 | return await application( |
| | 2024-10-13 18:02:23.466 | File "/usr/local/lib/python3.12/site-packages/channels/routing.py", line 132, in __call__ |
| | 2024-10-13 18:02:23.466 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:23.466 | return await self.inner(scope, receive, send) |
| | 2024-10-13 18:02:23.466 | File "/usr/local/lib/python3.12/site-packages/channels/middleware.py", line 24, in __call__ |
| | 2024-10-13 18:02:23.466 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:23.466 | return await super().__call__(scope, receive, send) |
| | 2024-10-13 18:02:23.466 | File "/usr/local/lib/python3.12/site-packages/channels/auth.py", line 185, in __call__ |
| | 2024-10-13 18:02:23.466 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:23.466 | return await self.inner(wrapper.scope, receive, wrapper.send) |
| | 2024-10-13 18:02:23.466 | File "/usr/local/lib/python3.12/site-packages/channels/sessions.py", line 263, in __call__ |
| | 2024-10-13 18:02:23.466 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:23.466 | return await self.inner(dict(scope, cookies=cookies), receive, send) |
| | 2024-10-13 18:02:23.466 | File "/usr/local/lib/python3.12/site-packages/channels/sessions.py", line 47, in __call__ |
| | 2024-10-13 18:02:23.466 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:23.466 | return await self.application(scope, receive, send) |
| | 2024-10-13 18:02:23.466 | File "/usr/local/lib/python3.12/site-packages/channels/security/websocket.py", line 37, in __call__ |
| | 2024-10-13 18:02:23.466 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| | 2024-10-13 18:02:23.466 | return await application(scope, receive, send) |
| | 2024-10-13 18:02:23.466 | File "/usr/local/lib/python3.12/site-packages/channels/routing.py", line 62, in __call__ |
| | 2024-10-13 18:02:23.466 | await inner(watcher.scope, watcher.proto) |
| | 2024-10-13 18:02:23.466 | File "/usr/local/lib/python3.12/site-packages/granian/_futures.py", line 4, in future_watcher |
| | 2024-10-13 18:02:23.466 | Traceback (most recent call last): |
| | 2024-10-13 18:02:23.466 | [ERROR] Application callable raised an exception
Not sure if this is related @gi0baro, however, I have this Application callable raised an exception
with frequency on Sentry. But in my case, I'm using Django and Django Channels 🤔
Very timely as I was looking into these errors today for our platform:
We are using websockets (purely for pushing notifications), but the flow error happens randomly and I don't have any ideas currently on how to debug it effectively. It doesn't appear to be impacting performance/useability (nothing reported anyway), but it'd be good to understand more about it.
2024-10-14T00:10:37.621926524Z [ERROR] Application callable raised an exception
2024-10-14T00:10:37.621976725Z Traceback (most recent call last):
2024-10-14T00:10:37.621985425Z File "/usr/local/lib/python3.12/site-packages/granian/_futures.py", line 4, in future_watcher
2024-10-14T00:10:37.621992626Z await inner(watcher.scope, watcher.proto)
2024-10-14T00:10:37.621998626Z File "/usr/local/lib/python3.12/site-packages/channels/routing.py", line 62, in __call__
2024-10-14T00:10:37.622003926Z return await application(scope, receive, send)
2024-10-14T00:10:37.622008926Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-10-14T00:10:37.622013726Z File "/usr/local/lib/python3.12/site-packages/channels/security/websocket.py", line 37, in __call__
2024-10-14T00:10:37.622019426Z return await self.application(scope, receive, send)
2024-10-14T00:10:37.622025026Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-10-14T00:10:37.622030226Z File "/usr/local/lib/python3.12/site-packages/channels/sessions.py", line 47, in __call__
2024-10-14T00:10:37.622035426Z return await self.inner(dict(scope, cookies=cookies), receive, send)
2024-10-14T00:10:37.622057427Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-10-14T00:10:37.622063227Z File "/usr/local/lib/python3.12/site-packages/channels/sessions.py", line 263, in __call__
2024-10-14T00:10:37.622069627Z return await self.inner(wrapper.scope, receive, wrapper.send)
2024-10-14T00:10:37.622075227Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-10-14T00:10:37.622079927Z File "/usr/local/lib/python3.12/site-packages/channels/auth.py", line 185, in __call__
2024-10-14T00:10:37.622085327Z return await super().__call__(scope, receive, send)
2024-10-14T00:10:37.622090527Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-10-14T00:10:37.622095527Z File "/usr/local/lib/python3.12/site-packages/channels/middleware.py", line 24, in __call__
2024-10-14T00:10:37.622100927Z return await self.inner(scope, receive, send)
2024-10-14T00:10:37.622105528Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-10-14T00:10:37.622109928Z File "/usr/local/lib/python3.12/site-packages/channels/routing.py", line 132, in __call__
2024-10-14T00:10:37.622114728Z return await application(
2024-10-14T00:10:37.622119828Z ^^^^^^^^^^^^^^^^^^
2024-10-14T00:10:37.622125328Z File "/usr/local/lib/python3.12/site-packages/channels/consumer.py", line 94, in app
2024-10-14T00:10:37.622130828Z return await consumer(scope, receive, send)
2024-10-14T00:10:37.622135728Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-10-14T00:10:37.622140728Z File "/usr/local/lib/python3.12/site-packages/channels/consumer.py", line 58, in __call__
2024-10-14T00:10:37.622146028Z await await_many_dispatch(
2024-10-14T00:10:37.622151828Z File "/usr/local/lib/python3.12/site-packages/channels/utils.py", line 57, in await_many_dispatch
2024-10-14T00:10:37.622157129Z await task
2024-10-14T00:10:37.622161929Z File "/usr/local/lib/python3.12/site-packages/channels/utils.py", line 49, in await_many_dispatch
2024-10-14T00:10:37.622167229Z result = task.result()
2024-10-14T00:10:37.622172129Z ^^^^^^^^^^^^^
2024-10-14T00:10:37.622177029Z RuntimeError: ASGI flow error
@Tragio @grant-oscillolabs it is quite hard for me to debug the almost cryptic stack traces of Django channels. It might be related to the OP or not; probably the best approach is to fix the original issue from the OP and let you check if that also covers your case. If not, then feel free to open a dedicated issue.
I get this error using FastAPI with granian (possibly related to #186). Repro:
Then just
new WebSocket("ws://localhost:8000").connect
in a browser console will trigger this error:Granian 1.6.0, FastAPI 0.115.2.