aiohttp-asgi icon indicating copy to clipboard operation
aiohttp-asgi copied to clipboard

Fix aiohttp_asgi with aiohttp>=3.10.6...

Open meyerj opened this issue 1 year ago • 1 comments

... with https://github.com/aio-libs/aiohttp/pull/9200, and forward websocket subprotocols from the request headers.

I probably shouldn't have mixed these two things, but this version works for me with

aiohttp==3.10.9
channels==4.1.0
Django==4.2.16

to run a Django application with Channels and web sockets as an ASGIResource from an aiohttp application.

Without this patch the following exception is raised:

[server-1] Traceback (most recent call last):
[server-1]   File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_protocol.py", line 477, in _handle_request
[server-1]     resp = await request_handler(request)
[server-1]   File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_app.py", line 559, in _handle
[server-1]     return await handler(request)
[server-1]   File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_middlewares.py", line 114, in impl
[server-1]     prev = match_info.current_app
[server-1] AttributeError: 'ASGIMatchInfo' object has no attribute 'current_app'

From aiohttp/CHANGES.rst:

Improved middleware performance -- by :user:bdraco.

The set_current_app method was removed from UrlMappingMatchInfo because it is no longer used, and it was unlikely external caller would ever use it.

Related issues and pull requests on GitHub: :issue:9200.

Likely the changes are not backwards compatible to older versions of aiohttp as-is...

Related to https://github.com/mosquito/aiohttp-asgi/pull/2.

meyerj avatar Nov 06 '24 13:11 meyerj

Fixed the issue for me

elthariel avatar Apr 24 '25 13:04 elthariel