Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Channels Daphne uvicorn

I wrote Django Channels for practice.

Use Daphne

daphne project.asgi:application

Everything works well.

Use uvicorn

uvicorn project.asgi:application

Error on the page

(index):16 WebSocket connection to'ws://127.0.0.1:8000/ws/chat/123/' failed: Error during WebSocket handshake: Unexpected response code: 400

I don't know where I went wrong.

I follow the official use

python -m pip install uvicorn gunicorn

gunicorn project.asgi:application -k uvicorn.workers.UvicornWorker

Error on the page

(index):16 WebSocket connection to'ws://127.0.0.1:8000/ws/chat/123/' failed: Error during WebSocket handshake: Unexpected response code: 400

Please help me where I need to improve, thank you.

like image 386
dudulu Avatar asked Jan 25 '26 07:01

dudulu


1 Answers

If you want to use websockets, you need to install uvicorn[standard]:

pip install uvicorn[standard]

See also https://www.uvicorn.org/#quickstart

like image 107
cmile Avatar answered Jan 29 '26 00:01

cmile



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!