django-channels

AttributeError in ASGI/Daphne Django problem

AttributeError in ASGI/Daphne Django problem Question: I had done this tutorial for WebSocket with Django but I have this problem when I execute "python manage.py runserver": HTTP GET /chat/hello/ 200 [0.01, 127.0.0.1:65009] WebSocket HANDSHAKING /ws/chat/hello/ [127.0.0.1:65014] Exception inside application: ‘int’ object has no attribute ‘decode’ Traceback (most recent call last): File "D:ProjectsNew Backendvenvlibsite-packagesdjangocontribstaticfileshandlers.py", line 101, …

Total answers: 2

Switched from WSGI to ASGI for Django Channels and now CircleCI throws "corrupted double-linked list" even though tests pass

Switched from WSGI to ASGI for Django Channels and now CircleCI throws "corrupted double-linked list" even though tests pass Question: I’ve been working on a project which requires WebSockets. The platform is built with Django and was running the WSGI server gunicorn. We decided to implement WebSockets using Django Channels. I set everything up including …

Total answers: 1

Django Channels is not taking over deployment server

Django Channels is not taking over deployment server Question: I am attempting Django Channels for the first time. I am following this tutorial – https://www.youtube.com/watch?v=cw8-KFVXpTE&t=21s – which basically explains Channels basics. I installed Channels in my virual environment using pip install channels and it installed the latest version, which is 4.0.0. I have laid out …

Total answers: 1

Django Channels: Channel Name type error appears when loading web socket chat

Django Channels: Channel Name type error appears when loading web socket chat Question: I’m building a basic websocket live chat using Django Channels and while the site loads fine, when I enter into the site, in my terminal I get this TypeError Message: TypeError: Channel name must be a valid unicode string with length < …

Total answers: 1

unable to understand how the group name is defined based on the chat room name while making a chat application using channels

unable to understand how the group name is defined based on the chat room name while making a chat application using channels Question: self.room_group_name = "chat_%s" % self.room_name This is the line of code that defines the room group name from the room_name in the official tutorial on the channels website. (https://channels.readthedocs.io/en/stable/tutorial/part_2.html) I am unable …

Total answers: 2

for message in messages: TypeError: 'Messages' object is not iterable

for message in messages: TypeError: 'Messages' object is not iterable Question: Am having issues with looping through an object here is my code from django.contrib.auth import get_user_model import json from asgiref.sync import async_to_sync from channels.generic.websocket import WebsocketConsumer from .models import Messages User = get_user_model() class ChatConsumer(WebsocketConsumer): def fetch_messages(self, data): messages = Messages.last_30_messages() content = { …

Total answers: 1

ASGI_APPLICATION not working with Django Channels

ASGI_APPLICATION not working with Django Channels Question: I followed the tutorial in the channels documentation but when I start the server python3 manage.py runserver it gives me this : Watching for file changes with StatReloader Performing system checks… System check identified no issues (0 silenced). October 17, 2022 – 00:13:21 Django version 4.1.2, using settings …

Total answers: 5

Real time chat application with Django Channels

Real time chat application with Django Channels Question: My real time chat application refuses to send message. no errors at all. I have tried tracing the errors by logging to the console at every stage passed and also tried printing to the terminal. I think the problem might be from consumers.py here is my consummers.py …

Total answers: 2

django async if else use a thread or sync_to_async

django async if else use a thread or sync_to_async Question: I don’t know where the error is. I am using Django ORM asynchronously. @database_sync_to_async def filter_data(**kwargs): return FinishAnimateModel.objects.filter(**kwargs) async def receive(self, text_data=None, bytes_data=None): … if data[‘msg’]: print(‘in’) model = await DB.Myself.filter_data(name__contains=”) print(‘ok’) else: print(‘else’) model = await DB.Myself.filter_data(name__contains=”) print(model, ‘model’) In if log in ok …

Total answers: 1