Skip to content

Missing 'scheme' key in ws scope #538

Open
@FelixFunk

Description

@FelixFunk

Environment

python: 3.11.5
aiofiles==23.2.1
blinker==1.8.2
click==8.1.7
Flask==3.0.3
h11==0.14.0
h2==4.1.0
hpack==4.0.0
Hypercorn==0.17.3
hyperframe==6.0.1
itsdangerous==2.2.0
Jinja2==3.1.4
MarkupSafe==2.1.5
pathvalidate==3.2.1
priority==2.0.0
PyJWT==2.9.0
pyzmq==26.0.3
Quart==0.19.6
Quart-JWT-Extended==0.1.0
six==1.16.0
Werkzeug==3.0.3
wsproto==1.2.0

OS: OpenSUSE Tumbleweed
Browser: Firefox 132.0.1

CMD

daphne run_service:quart_app -e ssl:44444:privateKey=../dev/ssl/key.pem:certKey=../dev/ssl/cert.pem

Issue

While running a Quart app i get the following stacktrace on a websocket request:

2024-11-06 17:01:34,181 | ERROR: Exception inside application: 'scheme' (server.py:297)
Traceback (most recent call last):
  File "/LOCAL/garcia/Projects/triplaystudio/.venv/lib/python3.11/site-packages/quart/app.py", line 1667, in __call__
    await self.asgi_app(scope, receive, send)
  File "/LOCAL/garcia/Projects/triplaystudio/.venv/lib/python3.11/site-packages/quart/app.py", line 1693, in asgi_app
    await asgi_handler(receive, send)
  File "/LOCAL/garcia/Projects/triplaystudio/.venv/lib/python3.11/site-packages/quart/asgi.py", line 166, in __call__
    websocket = self._create_websocket_from_scope(send)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/LOCAL/garcia/Projects/triplaystudio/.venv/lib/python3.11/site-packages/quart/asgi.py", line 204, in _create_websocket_from_scope
    self.scope["scheme"],
    ~~~~~~~~~~^^^^^^^^^^
KeyError: 'scheme'
10.242.2.5:57258 - - [06/Nov/2024:17:01:34] "WSDISCONNECT /conn" - -

It seems like the 'scheme' property is missing for the websocket connection scope. I am not 100% sure if this issue belongs to daphne, since the asgi documentation marks 'scheme' as an optional setting. However, the documentation also states 'but must not be empty'. If this is indeed related to the Quart project i am really sorry for posting it here. I tested the same code with Hypercorn, so the actual request itself should not be an issue here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions