Broken Pipe Error Comes When Hit Url In Websocketking

When i Hit This Url Then This Error Comes
Error On My Terminal

[31/Oct/2023 10:46:05] "GET /ws/ HTTP/1.1" 404 2090
[31/Oct/2023 10:46:08] "GET / HTTP/1.1" 200 10664
[31/Oct/2023 10:46:08,884] - Broken pipe from ('', 43236)
Not Found: /ws/test/
[31/Oct/2023 10:46:11] "GET /ws/test/ HTTP/1.1" 404 2105
[31/Oct/2023 10:46:11,513] - Broken pipe from ('', 43252)


from channels.generic.websocket import WebsocketConsumer
from asgiref.sync import async_to_sync
import json

class TestConsumer(WebsocketConsumer):
    def connect(self):
        self.room_name = "test_consumer"
        self.room_group_name = "test_consumer_group"
            self.room_name, self.room_group_name
        self.send(text_data=json.dumps({'status': 'Connected'}))

    def receive(self, text_data):

    def disconnect(self, close_code):

import os
from channels.routing import ProtocolTypeRouter, URLRouter
from django.urls import path
from django.core.asgi import get_asgi_application
from myapp.consumers import TestConsumer

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mychannels.settings')

application = get_asgi_application()
ws_patterns = [
    path('ws/test/', TestConsumer)
application = ProtocolTypeRouter({
    'websocket': URLRouter(ws_patterns)

ASGI_APPLICATION = 'mychannels.asgi.application'
channels_layers = {
    'default': {
        'BACKEND': 'channels_redis.core.RedisChannelLayer',
        'CONFIG': {
            'hosts': [('localhost', 6379)],

First, I would suggest that you follow the patterns and structure of the consumer, routing, urls, etc as shown in Tutorial Part 2: Implement a Chat Server — Channels 4.0.0 documentation exactly as presented, until you get this working. In my experience, that has been the easiest way to get this started.

Second, you’ve got two different definitions for the variable application in your file.

Finally, it appears you’re looking to run this instance as “websocket” only? You’re not looking to have this serve any routine http requests? If so, there are other changes that need to be made in that file.

One time I was also getting broken pipe error.
I don’t know how but when I used this with redis my problem my gone.

I think you should also try this method