emmett-framework / granian

A Rust HTTP server for Python applications
BSD 3-Clause "New" or "Revised" License
2.67k stars 79 forks source link

ASGI Flow Error and "Code" key error after migrating from Daphne #184

Closed cyb3rs3ntry closed 8 months ago

cyb3rs3ntry commented 8 months ago

Getting ASGI Flow errors and "code" key errors after migrating fro daphne -> Granian. I didn't see these issues before with daphne. I've spent a day trying to troubleshoot this and I'm not sure what else could be missing. Any advice is appreciated.

Also here is the command I'm using to run granian in my docker compose file

command: ["granian", "--interface", "asgi", "myapp.asgi:application", "--host", "0.0.0.0", "--port","8000"]

[WARNING] Application callable raised an exception
2024-01-23T23:25:00.896092556Z ERROR:asyncio:Task exception was never retrieved
2024-01-23T23:25:00.896137548Z future: <Task finished name='Task-37' coro=<future_watcher_wrapper.<locals>.future_watcher() done, defined at /usr/local/lib/python3.11/site-packages/granian/_futures.py:2> exception=KeyError('code')>
2024-01-23T23:25:00.896142843Z Traceback (most recent call last):
2024-01-23T23:25:00.896146015Z   File "/usr/local/lib/python3.11/site-packages/granian/_futures.py", line 4, in future_watcher
2024-01-23T23:25:00.896149816Z     await inner(watcher.scope, watcher.proto)
2024-01-23T23:25:00.896152347Z   File "/usr/local/lib/python3.11/site-packages/channels/routing.py", line 62, in __call__
2024-01-23T23:25:00.896155469Z     return await application(scope, receive, send)
2024-01-23T23:25:00.896157916Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-23T23:25:00.896160929Z   File "/usr/local/lib/python3.11/site-packages/channels/security/websocket.py", line 37, in __call__
2024-01-23T23:25:00.896182331Z     return await self.application(scope, receive, send)
2024-01-23T23:25:00.896185407Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-23T23:25:00.896188445Z   File "/usr/local/lib/python3.11/site-packages/channels/sessions.py", line 47, in __call__
2024-01-23T23:25:00.896191103Z     return await self.inner(dict(scope, cookies=cookies), receive, send)
2024-01-23T23:25:00.896194080Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-23T23:25:00.896196824Z   File "/usr/local/lib/python3.11/site-packages/channels/sessions.py", line 263, in __call__
2024-01-23T23:25:00.896199804Z     return await self.inner(wrapper.scope, receive, wrapper.send)
2024-01-23T23:25:00.896202799Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-23T23:25:00.896205195Z   File "/usr/local/lib/python3.11/site-packages/channels/auth.py", line 185, in __call__
2024-01-23T23:25:00.896207695Z     return await super().__call__(scope, receive, send)
2024-01-23T23:25:00.896210699Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-23T23:25:00.896214704Z   File "/usr/local/lib/python3.11/site-packages/channels/middleware.py", line 24, in __call__
2024-01-23T23:25:00.896217359Z     return await self.inner(scope, receive, send)
2024-01-23T23:25:00.896219748Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-23T23:25:00.896222127Z   File "/usr/local/lib/python3.11/site-packages/channels/routing.py", line 116, in __call__
2024-01-23T23:25:00.896225155Z     return await application(
2024-01-23T23:25:00.896227584Z            ^^^^^^^^^^^^^^^^^^
2024-01-23T23:25:00.896230469Z   File "/usr/local/lib/python3.11/site-packages/channels/consumer.py", line 94, in app
2024-01-23T23:25:00.896233051Z     return await consumer(scope, receive, send)
2024-01-23T23:25:00.896235529Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-23T23:25:00.896244699Z   File "/usr/local/lib/python3.11/site-packages/channels/consumer.py", line 58, in __call__
2024-01-23T23:25:00.896248046Z     await await_many_dispatch(
2024-01-23T23:25:00.896250543Z   File "/usr/local/lib/python3.11/site-packages/channels/utils.py", line 50, in await_many_dispatch
2024-01-23T23:25:00.896253225Z     await dispatch(result)
2024-01-23T23:25:00.896255709Z   File "/usr/local/lib/python3.11/site-packages/channels/consumer.py", line 73, in dispatch
2024-01-23T23:25:00.896258713Z     await handler(message)
2024-01-23T23:25:00.896262178Z   File "/usr/local/lib/python3.11/site-packages/channels/generic/websocket.py", line 238, in websocket_disconnect
2024-01-23T23:25:00.896265392Z     await self.disconnect(message["code"])
2024-01-23T23:25:00.896268612Z                           ~~~~~~~^^^^^^^^
2024-01-23T23:25:00.896271615Z KeyError: 'code'
2024-01-23T23:26:01.106000624Z [WARNING] Application callable raised an exception
2024-01-23T23:26:01.107619140Z ERROR:asyncio:Task exception was never retrieved
2024-01-23T23:26:01.107677944Z future: <Task finished name='Task-50' coro=<future_watcher_wrapper.<locals>.future_watcher() done, defined at /usr/local/lib/python3.11/site-packages/granian/_futures.py:2> exception=RuntimeError('ASGI flow error')>
2024-01-23T23:26:01.107689356Z Traceback (most recent call last):
2024-01-23T23:26:01.107693063Z   File "/usr/local/lib/python3.11/site-packages/granian/_futures.py", line 4, in future_watcher
2024-01-23T23:26:01.107696779Z     await inner(watcher.scope, watcher.proto)
2024-01-23T23:26:01.107699578Z   File "/usr/local/lib/python3.11/site-packages/channels/routing.py", line 62, in __call__
2024-01-23T23:26:01.107702857Z     return await application(scope, receive, send)
2024-01-23T23:26:01.107705862Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-23T23:26:01.107708883Z   File "/usr/local/lib/python3.11/site-packages/channels/security/websocket.py", line 37, in __call__
2024-01-23T23:26:01.107712161Z     return await self.application(scope, receive, send)
2024-01-23T23:26:01.107715253Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-23T23:26:01.107717927Z   File "/usr/local/lib/python3.11/site-packages/channels/sessions.py", line 47, in __call__
2024-01-23T23:26:01.107721197Z     return await self.inner(dict(scope, cookies=cookies), receive, send)
2024-01-23T23:26:01.107724298Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-23T23:26:01.107726928Z   File "/usr/local/lib/python3.11/site-packages/channels/sessions.py", line 263, in __call__
2024-01-23T23:26:01.107729683Z     return await self.inner(wrapper.scope, receive, wrapper.send)
2024-01-23T23:26:01.107732714Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-23T23:26:01.107735356Z   File "/usr/local/lib/python3.11/site-packages/channels/auth.py", line 185, in __call__
2024-01-23T23:26:01.107738057Z     return await super().__call__(scope, receive, send)
2024-01-23T23:26:01.107740651Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-23T23:26:01.107743712Z   File "/usr/local/lib/python3.11/site-packages/channels/middleware.py", line 24, in __call__
2024-01-23T23:26:01.107746873Z     return await self.inner(scope, receive, send)
2024-01-23T23:26:01.107749884Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-23T23:26:01.107752457Z   File "/usr/local/lib/python3.11/site-packages/channels/routing.py", line 116, in __call__
2024-01-23T23:26:01.107755164Z     return await application(
2024-01-23T23:26:01.107758133Z            ^^^^^^^^^^^^^^^^^^
2024-01-23T23:26:01.107761026Z   File "/usr/local/lib/python3.11/site-packages/channels/consumer.py", line 94, in app
2024-01-23T23:26:01.107763780Z     return await consumer(scope, receive, send)
2024-01-23T23:26:01.107778901Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-23T23:26:01.107784762Z   File "/usr/local/lib/python3.11/site-packages/channels/consumer.py", line 58, in __call__
2024-01-23T23:26:01.107788248Z     await await_many_dispatch(
2024-01-23T23:26:01.107790797Z   File "/usr/local/lib/python3.11/site-packages/channels/utils.py", line 57, in await_many_dispatch
2024-01-23T23:26:01.107793486Z     await task
2024-01-23T23:26:01.107796044Z RuntimeError: ASGI flow error