Not able to connect to WebsocketConsumer

First thing I’d suggest is fixing your asgi.py file such that the general structure and sequence of events is exactly as shown in the Channels tutorial at Tutorial Part 2: Implement a Chat Server — Channels 4.1.0 documentation.

Do not shorten the code. Do not reorganize or reorder anything.