Skip to content

2026.5.0: Exception in ASGI application #22602

Description

@cheggerdev

Describe the bug

I noticed an "Exception in ASGI application" in the server logs.

How to reproduce

Not sure. I just looked into the server logs...
Beside that Authentik was idle.

Expected behavior

an exception with a trace should not be there at all :)

Screenshots

No response

Additional context

No response

Deployment Method

Docker

Version

2026.5.0

Relevant log output

authentik-server-1  | {"auth_via": "api_token", "domain_url": null, "event": "runtime error during accept", "exc": "RuntimeError(\"Expected ASGI message 'websocket.send' or 'websocket.close', but got 'websocket.accept'.\")", "level": "warning", "logger": "authentik.outposts.consumer", "outpost": "<Outpost: Outpost Radius Outpost>", "pid": 16147, "schema_name": "public", "timestamp": "2026-05-22T19:33:47.311087"}
authentik-server-1  | {"auth_via": "api_token", "domain_url": null, "event": "Exception in ASGI application", "exc": "ClientDisconnected()", "level": "warning", "logger": "authentik.asgi", "pid": 16147, "schema_name": "public", "timestamp": "2026-05-22T19:33:47.313754"}
authentik-server-1  | Exception in ASGI application
authentik-server-1  | Traceback (most recent call last):
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/uvicorn/protocols/websockets/wsproto_impl.py", line 327, in run_asgi
authentik-server-1  |     result = await self.app(self.scope, self.receive, self.send)  # type: ignore[func-returns-value]
authentik-server-1  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/uvicorn/middleware/proxy_headers.py", line 56, in __call__
authentik-server-1  |     return await self.app(scope, receive, send)
authentik-server-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/sentry_sdk/integrations/asgi.py", line 184, in _run_asgi3
authentik-server-1  |     return await self._run_app(scope, receive, send, asgi_version=3)
authentik-server-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/sentry_sdk/integrations/asgi.py", line 360, in _run_app
authentik-server-1  |     raise exc from None
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/sentry_sdk/integrations/asgi.py", line 348, in _run_app
authentik-server-1  |     return await self.app(
authentik-server-1  |            ^^^^^^^^^^^^^^^
authentik-server-1  |         scope, receive, _sentry_wrapped_send
authentik-server-1  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
authentik-server-1  |     )
authentik-server-1  |     ^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/channels/routing.py", line 48, in __call__
authentik-server-1  |     return await application(scope, receive, send)
authentik-server-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
authentik-server-1  |   File "/authentik/root/asgi.py", line 56, in __call__
authentik-server-1  |     return await self.app(scope, receive, send)
authentik-server-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/channels/routing.py", line 118, in __call__
authentik-server-1  |     return await application(
authentik-server-1  |            ^^^^^^^^^^^^^^^^^^
authentik-server-1  |     ...<10 lines>...
authentik-server-1  |     )
authentik-server-1  |     ^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/channels/routing.py", line 118, in __call__
authentik-server-1  |     return await application(
authentik-server-1  |            ^^^^^^^^^^^^^^^^^^
authentik-server-1  |     ...<10 lines>...
authentik-server-1  |     )
authentik-server-1  |     ^
authentik-server-1  |   File "/authentik/root/middleware.py", line 303, in __call__
authentik-server-1  |     return await send({"type": "websocket.close"})
authentik-server-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/sentry_sdk/integrations/asgi.py", line 341, in _sentry_wrapped_send
authentik-server-1  |     return await send(event)
authentik-server-1  |            ^^^^^^^^^^^^^^^^^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/uvicorn/protocols/websockets/wsproto_impl.py", line 451, in send
authentik-server-1  |     raise RuntimeError(f"Unexpected ASGI message '{message['type']}', after sending 'websocket.close'.")
authentik-server-1  | RuntimeError: Unexpected ASGI message 'websocket.close', after sending 'websocket.close'.
authentik-server-1  | {"auth_via": "api_token", "domain_url": null, "event": "runtime error during accept", "exc": "RuntimeError(\"Expected ASGI message 'websocket.send' or 'websocket.close', but got 'websocket.accept'.\")", "level": "warning", "logger": "authentik.outposts.consumer", "outpost": "<Outpost: Outpost Radius Outpost>", "pid": 18663, "schema_name": "public", "timestamp": "2026-05-22T19:33:50.488470"}
authentik-server-1  | {"auth_via": "api_token", "domain_url": null, "event": "Exception in ASGI application", "exc": "ClientDisconnected()", "level": "warning", "logger": "authentik.asgi", "pid": 18663, "schema_name": "public", "timestamp": "2026-05-22T19:33:50.490863"}
authentik-server-1  | Exception in ASGI application
authentik-server-1  | Traceback (most recent call last):
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/uvicorn/protocols/websockets/wsproto_impl.py", line 327, in run_asgi
authentik-server-1  |     result = await self.app(self.scope, self.receive, self.send)  # type: ignore[func-returns-value]
authentik-server-1  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/uvicorn/middleware/proxy_headers.py", line 56, in __call__
authentik-server-1  |     return await self.app(scope, receive, send)
authentik-server-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/sentry_sdk/integrations/asgi.py", line 184, in _run_asgi3
authentik-server-1  |     return await self._run_app(scope, receive, send, asgi_version=3)
authentik-server-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/sentry_sdk/integrations/asgi.py", line 360, in _run_app
authentik-server-1  |     raise exc from None
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/sentry_sdk/integrations/asgi.py", line 348, in _run_app
authentik-server-1  |     return await self.app(
authentik-server-1  |            ^^^^^^^^^^^^^^^
authentik-server-1  |         scope, receive, _sentry_wrapped_send
authentik-server-1  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
authentik-server-1  |     )
authentik-server-1  |     ^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/channels/routing.py", line 48, in __call__
authentik-server-1  |     return await application(scope, receive, send)
authentik-server-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
authentik-server-1  |   File "/authentik/root/asgi.py", line 56, in __call__
authentik-server-1  |     return await self.app(scope, receive, send)
authentik-server-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/channels/routing.py", line 118, in __call__
authentik-server-1  |     return await application(
authentik-server-1  |            ^^^^^^^^^^^^^^^^^^
authentik-server-1  |     ...<10 lines>...
authentik-server-1  |     )
authentik-server-1  |     ^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/channels/routing.py", line 118, in __call__
authentik-server-1  |     return await application(
authentik-server-1  |            ^^^^^^^^^^^^^^^^^^
authentik-server-1  |     ...<10 lines>...
authentik-server-1  |     )
authentik-server-1  |     ^
authentik-server-1  |   File "/authentik/root/middleware.py", line 303, in __call__
authentik-server-1  |     return await send({"type": "websocket.close"})
authentik-server-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/sentry_sdk/integrations/asgi.py", line 341, in _sentry_wrapped_send
authentik-server-1  |     return await send(event)
authentik-server-1  |            ^^^^^^^^^^^^^^^^^
authentik-server-1  |   File "/ak-root/.venv/lib/python3.14/site-packages/uvicorn/protocols/websockets/wsproto_impl.py", line 451, in send
authentik-server-1  |     raise RuntimeError(f"Unexpected ASGI message '{message['type']}', after sending 'websocket.close'.")
authentik-server-1  | RuntimeError: Unexpected ASGI message 'websocket.close', after sending 'websocket.close'.
authentik-server-1  | {"domain_url": null, "event": "/ws/outpost/202ffaf2-06a9-4bb1-8853-d7be29769818/", "level": "info", "logger": "authentik.asgi", "pid": 16147, "remote": "172.16.1.7", "schema_name": "public", "scheme": "ws", "timestamp": "2026-05-22T19:33:58.330293", "user_agent": "goauthentik.io/outpost/2026.5.0"}

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingbug/confirmedConfirmed bugs

Type

Projects

Status
Done

Relationships

None yet

Development

No branches or pull requests

Issue actions