# Async/Channels

**URL:** https://forum.djangoproject.com/c/users/async-channels/23.md?page=1

[Latest](https://forum.djangoproject.com/latest.md) · [Categories](https://forum.djangoproject.com/categories.md) · [Tags](https://forum.djangoproject.com/tags.md)

**Page:** 2

---

## [asgiref: does the number of sync\_to\_async calls matter](https://forum.djangoproject.com/t/asgiref-does-the-number-of-sync-to-async-calls-matter/39292)

<div class="topic-metadata">

**Author:** [@amirreza8002](https://forum.djangoproject.com/u/amirreza8002)\
**Replies:** 3\
**Last updated:** [March 5, 2025, 6:28pm UTC](https://forum.djangoproject.com/t/asgiref-does-the-number-of-sync-to-async-calls-matter/39292 "2025-03-05T18:28:58Z")

</div>

hi so i understand that sync\_to\_async calls of a request cycle all use the same threadpool but i’m wondering if the number of sync\_to\_async calls would cause an overhead so if i manage to reduce 5 calls into 2, will t…

---

## [Running multiplayer game loop with django channels](https://forum.djangoproject.com/t/running-multiplayer-game-loop-with-django-channels/39113)

<div class="topic-metadata">

**Author:** [@emuminov](https://forum.djangoproject.com/u/emuminov)\
**Replies:** 5\
**Last updated:** [February 27, 2025, 6:49pm UTC](https://forum.djangoproject.com/t/running-multiplayer-game-loop-with-django-channels/39113 "2025-02-27T18:49:29Z")

</div>

Hello everyone. It is easy to find information on how to implement a chat server or a turn base multiplayer game with Django channels, but it’s much harder to find on how to create real-time multiplayer game, like a web…

---

## [ASGI, "MySQL server has gone away" and CONN\_MAX\_AGE](https://forum.djangoproject.com/t/asgi-mysql-server-has-gone-away-and-conn-max-age/5240)

<div class="topic-metadata">

**Author:** [@ZymosisNN](https://forum.djangoproject.com/u/ZymosisNN)\
**Replies:** 8\
**Last updated:** [February 27, 2025, 5:32pm UTC](https://forum.djangoproject.com/t/asgi-mysql-server-has-gone-away-and-conn-max-age/5240 "2025-02-27T17:32:02Z")

</div>

I have an ASGI Django (v3.1) application and MariaDB. The problem is: DB drops idle connection after wait\_timeout and after I open a page I get an exception: MySQLdb.\_exceptions.OperationalError: (2006, 'MySQL server h…

---

## [Websocket + Django on production (https)](https://forum.djangoproject.com/t/websocket-django-on-production-https/19424)

<div class="topic-metadata">

**Author:** [@mtb](https://forum.djangoproject.com/u/mtb)\
**Replies:** 25\
**Last updated:** [February 26, 2025, 1:04am UTC](https://forum.djangoproject.com/t/websocket-django-on-production-https/19424 "2025-02-26T01:04:43Z")

</div>

Dear guys, I am struggling with deployment of my web app that contains real time chat as a feature. The web app works fine on localhost. When it comes to deployment to production + https, the websocket client (browser…

---

## [database\_sync\_to\_async calls causing asyncio.CanceledError](https://forum.djangoproject.com/t/database-sync-to-async-calls-causing-asyncio-cancelederror/38998)

<div class="topic-metadata">

**Author:** [@arcanjo45](https://forum.djangoproject.com/u/arcanjo45)\
**Replies:** 3\
**Last updated:** [February 21, 2025, 2:28pm UTC](https://forum.djangoproject.com/t/database-sync-to-async-calls-causing-asyncio-cancelederror/38998 "2025-02-21T14:28:00Z")

</div>

I’m facing an odd behavior on one of my applications. So I have an application that has an POST entrypoint that receives a list of order id’s and after processing each order it must inform an external API about the monet…

---

## [ASGI/WSGI with Channels Behind Nginx - Is my app even running?](https://forum.djangoproject.com/t/asgi-wsgi-with-channels-behind-nginx-is-my-app-even-running/38825)

<div class="topic-metadata">

**Author:** [@cory5643](https://forum.djangoproject.com/u/cory5643)\
**Replies:** 2\
**Last updated:** [February 20, 2025, 4:14am UTC](https://forum.djangoproject.com/t/asgi-wsgi-with-channels-behind-nginx-is-my-app-even-running/38825 "2025-02-20T04:14:24Z")

</div>

Hi, I am a beginner learning more about deploying Django projects with async components. I have a small grasp of a good architecture from this discussion, and am looking to learn the mechanics. So, I have a dockerfil…

---

## [Issue in django channels ASGI server - (TypeError: object HttpResponse can't be used in 'await' expression)](https://forum.djangoproject.com/t/issue-in-django-channels-asgi-server-typeerror-object-httpresponse-cant-be-used-in-await-expression/38815)

<div class="topic-metadata">

**Author:** [@dinesh1299](https://forum.djangoproject.com/u/dinesh1299)\
**Replies:** 4\
**Last updated:** [February 14, 2025, 9:16am UTC](https://forum.djangoproject.com/t/issue-in-django-channels-asgi-server-typeerror-object-httpresponse-cant-be-used-in-await-expression/38815 "2025-02-14T09:16:53Z")

</div>

We’re integrating django channels to our existing django application built with wsgi server, but when integrating channels to our application documentation suggests to use daphne but when we hit any other API’s it is tho…

---

## [Django 4.2.16 + Daphne 4.1.2 http requests timeout result main thread deadlock](https://forum.djangoproject.com/t/django-4-2-16-daphne-4-1-2-http-requests-timeout-result-main-thread-deadlock/38835)

<div class="topic-metadata">

**Author:** [@luxiaoyong](https://forum.djangoproject.com/u/luxiaoyong)\
**Replies:** 0\
**Last updated:** [February 14, 2025, 5:55am UTC](https://forum.djangoproject.com/t/django-4-2-16-daphne-4-1-2-http-requests-timeout-result-main-thread-deadlock/38835 "2025-02-14T05:55:22Z")

</div>

The old version used WSGI for HTTP requests, but after upgrading to Django 4.2.16 + Daphne 4.1.2, HTTP requests now use ASGI. However, the view functions remain synchronous functions. We found that after an interface tim…

---

## [Starting the daphne service, the main thread is locked.](https://forum.djangoproject.com/t/starting-the-daphne-service-the-main-thread-is-locked/38727)

<div class="topic-metadata">

**Author:** [@luxiaoyong](https://forum.djangoproject.com/u/luxiaoyong)\
**Replies:** 0\
**Last updated:** [February 10, 2025, 11:08am UTC](https://forum.djangoproject.com/t/starting-the-daphne-service-the-main-thread-is-locked/38727 "2025-02-10T11:08:59Z")

</div>

Python 3.11 + Django 4.2.17 + asgiref 3.8.1 + daphne 4.1.2 Command: daphne health\_inspect.asgi:application --bind 127.0.0.1 --port 8002 --application\_close\_timeout 10 Using Daphne as the server, run the following comm…

---

## [group\_send fired but consumer is not receiving](https://forum.djangoproject.com/t/group-send-fired-but-consumer-is-not-receiving/38367)

<div class="topic-metadata">

**Author:** [@B4sic101](https://forum.djangoproject.com/u/B4sic101)\
**Replies:** 28\
**Last updated:** [February 1, 2025, 12:25pm UTC](https://forum.djangoproject.com/t/group-send-fired-but-consumer-is-not-receiving/38367 "2025-02-01T12:25:33Z")

</div>

Currently, the only prints that are not outputting are the ones in the frNotifier, heres settings.py: CHANNEL\_LAYERS = { "default": { "BACKEND": "channels.layers.InMemoryChannelLayer" } } ASGI\_APPLICATI…

---

## [Web Sockets - Streaming app](https://forum.djangoproject.com/t/web-sockets-streaming-app/38106)

<div class="topic-metadata">

**Author:** [@TommyQuality](https://forum.djangoproject.com/u/TommyQuality)\
**Replies:** 42\
**Last updated:** [January 25, 2025, 2:43pm UTC](https://forum.djangoproject.com/t/web-sockets-streaming-app/38106 "2025-01-25T14:43:56Z")

</div>

Hi, Im after some advice. I want to build a kind of terminal app, where content will be loaded in the screen in realtime, or as close as. This will be based on comments from users. bit like a chat system. I’ve looked …

---

## [Race condition? ASGI, asyncio, & asgiref.sync\_to\_async... oh my!!!](https://forum.djangoproject.com/t/race-condition-asgi-asyncio-asgiref-sync-to-async-oh-my/38139)

<div class="topic-metadata">

**Author:** [@khalide](https://forum.djangoproject.com/u/khalide)\
**Replies:** 5\
**Last updated:** [January 22, 2025, 9:38pm UTC](https://forum.djangoproject.com/t/race-condition-asgi-asyncio-asgiref-sync-to-async-oh-my/38139 "2025-01-22T21:38:11Z")

</div>

I’m facing a mysterious issue, perhaps a race condition, perhaps clashing event loops, perhaps something different altogether. I’m relatively new to async and unsure how best to debug. This scenario also doesn’t seem to …

---

## [WebSocket shuts down after X amount of time](https://forum.djangoproject.com/t/websocket-shuts-down-after-x-amount-of-time/38021)

<div class="topic-metadata">

**Author:** [@tumpa02](https://forum.djangoproject.com/u/tumpa02)\
**Replies:** 8\
**Last updated:** [January 17, 2025, 2:51pm UTC](https://forum.djangoproject.com/t/websocket-shuts-down-after-x-amount-of-time/38021 "2025-01-17T14:51:35Z")

</div>

Heya everyone, I have a React/JS & Django Rest Framework project. A part of the project is a chat which was made using websockets through django-channels. The application is deployed using Nginx as a reverse proxy for …

---

## [regarding channels and chat functionality in app](https://forum.djangoproject.com/t/regarding-channels-and-chat-functionality-in-app/37682)

<div class="topic-metadata">

**Author:** [@engineeringLearner](https://forum.djangoproject.com/u/engineeringLearner)\
**Replies:** 0\
**Last updated:** [January 4, 2025, 10:11am UTC](https://forum.djangoproject.com/t/regarding-channels-and-chat-functionality-in-app/37682 "2025-01-04T10:11:18Z")

</div>

So i am creating a sort of roomate finder application with the help of rest framework and django primarily handling backend on my part, so i wish to implement chat functionality between matched users for which i have alr…

---

## [ASGI Server in Development?](https://forum.djangoproject.com/t/asgi-server-in-development/37581)

<div class="topic-metadata">

**Author:** [@interglobalmedia](https://forum.djangoproject.com/u/interglobalmedia)\
**Replies:** 12\
**Last updated:** [January 2, 2025, 11:32am UTC](https://forum.djangoproject.com/t/asgi-server-in-development/37581 "2025-01-02T11:32:32Z")

</div>

Is it possible to use ASGI in development" Especially when the cloud platform I am deploying to uses ASGI, and certain code behaves differently in production from development. I have synchronous code which works beautif…

---

## [ValueError: No route found for path 'ws/student/start-exam/2'.](https://forum.djangoproject.com/t/valueerror-no-route-found-for-path-ws-student-start-exam-2/37505)

<div class="topic-metadata">

**Author:** [@taaddele](https://forum.djangoproject.com/u/taaddele)\
**Replies:** 26\
**Last updated:** [December 28, 2024, 12:08pm UTC](https://forum.djangoproject.com/t/valueerror-no-route-found-for-path-ws-student-start-exam-2/37505 "2024-12-28T12:08:43Z")

</div>

consumer.py ‘’'import json import asyncio from datetime import datetime, timedelta from channels.generic.websocket import AsyncWebsocketConsumer from django.db.models import ObjectDoesNotExist class CountdownConsum…

---

## [The performance boosting for real-time data displaying in Django](https://forum.djangoproject.com/t/the-performance-boosting-for-real-time-data-displaying-in-django/37317)

<div class="topic-metadata">

**Author:** [@carlosjobimjr](https://forum.djangoproject.com/u/carlosjobimjr)\
**Replies:** 0\
**Last updated:** [December 18, 2024, 11:33pm UTC](https://forum.djangoproject.com/t/the-performance-boosting-for-real-time-data-displaying-in-django/37317 "2024-12-18T23:33:11Z")

</div>

I’m experiencing persistent connectivity issues in an industrial setup involving three main components: an Ubuntu Server (x.x.y.z) running Django web application, an Ubuntu Desktop (x.x.y.t) accessing the web interface, …

---

## [current workaround for async auth backend](https://forum.djangoproject.com/t/current-workaround-for-async-auth-backend/37010)

<div class="topic-metadata">

**Author:** [@vanyakosmos](https://forum.djangoproject.com/u/vanyakosmos)\
**Replies:** 3\
**Last updated:** [December 17, 2024, 6:13am UTC](https://forum.djangoproject.com/t/current-workaround-for-async-auth-backend/37010 "2024-12-17T06:13:19Z")

</div>

I’ve seen in django code base that BaseBackend already has aauthenticate and aget\_user methods, but right now for the latest django 5.1.4 they are not available. What should I do if I need to load users from external sou…

---

## [Using async class-based views](https://forum.djangoproject.com/t/using-async-class-based-views/37039)

<div class="topic-metadata">

**Author:** [@billyt](https://forum.djangoproject.com/u/billyt)\
**Replies:** 1\
**Last updated:** [December 6, 2024, 10:05am UTC](https://forum.djangoproject.com/t/using-async-class-based-views/37039 "2024-12-06T10:05:37Z")

</div>

Hi, The docs say the following about using async with CBVs: Any view can be declared async by making the callable part of it return a coroutine - commonly, this is done using async def. For a function-based view, this…

---

## [Sending Message back to Client using Django Channels (and REST Framework)](https://forum.djangoproject.com/t/sending-message-back-to-client-using-django-channels-and-rest-framework/36873)

<div class="topic-metadata">

**Author:** [@lt-shy-john](https://forum.djangoproject.com/u/lt-shy-john)\
**Replies:** 3\
**Last updated:** [December 5, 2024, 10:45pm UTC](https://forum.djangoproject.com/t/sending-message-back-to-client-using-django-channels-and-rest-framework/36873 "2024-12-05T22:45:27Z")

</div>

I have just started to use Django channels with djangochannelrestframework and playing around with it. Right now I am trying to let the server side send me back messages to my browser (Not to group). Here is my code: co…

---

## [\[WebSocket\]\[Django\]\[Vite\]\[Docker\] Issue with WebSocket Routes in Development Mode, while it works in production](https://forum.djangoproject.com/t/websocket-django-vite-docker-issue-with-websocket-routes-in-development-mode-while-it-works-in-production/36895)

<div class="topic-metadata">

**Author:** [@lucaslopes](https://forum.djangoproject.com/u/lucaslopes)\
**Replies:** 2\
**Last updated:** [December 3, 2024, 10:54am UTC](https://forum.djangoproject.com/t/websocket-django-vite-docker-issue-with-websocket-routes-in-development-mode-while-it-works-in-production/36895 "2024-12-03T10:54:07Z")

</div>

Hello everyone, I am encountering an issue when running my application in development mode where all WebSocket routes fail to work. This problem does not occur in production mode when using Nginx. Below is a screenshot…

---

## [Django Channel Connection Refused in Production](https://forum.djangoproject.com/t/django-channel-connection-refused-in-production/36445)

<div class="topic-metadata">

**Author:** [@muhammad-sewts](https://forum.djangoproject.com/u/muhammad-sewts)\
**Replies:** 11\
**Last updated:** [November 21, 2024, 1:32pm UTC](https://forum.djangoproject.com/t/django-channel-connection-refused-in-production/36445 "2024-11-21T13:32:09Z")

</div>

Hi, I’m currently implementing Django Channels for asynchronous communication. The setup works flawlessly on my local environment, but when deployed in production (Docker container), I encounter a “connection refused” e…

---

## [AttributeError: 'coroutine' object has no attribute 'status\_code'](https://forum.djangoproject.com/t/attributeerror-coroutine-object-has-no-attribute-status-code/36387)

<div class="topic-metadata">

**Author:** [@mamunish](https://forum.djangoproject.com/u/mamunish)\
**Replies:** 8\
**Last updated:** [November 14, 2024, 12:13pm UTC](https://forum.djangoproject.com/t/attributeerror-coroutine-object-has-no-attribute-status-code/36387 "2024-11-14T12:13:02Z")

</div>

This is error message Traceback (most recent call last): File "myenv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner response = get\_response(request) File "/myenv/lib/python3.9/site-pac…

---

## [Drf channels](https://forum.djangoproject.com/t/drf-channels/36162)

<div class="topic-metadata">

**Author:** [@kinging1022](https://forum.djangoproject.com/u/kinging1022)\
**Replies:** 0\
**Last updated:** [November 4, 2024, 3:17am UTC](https://forum.djangoproject.com/t/drf-channels/36162 "2024-11-04T03:17:44Z")

</div>

I want to filter the model information pass down from my consumer.py using Django rest framework channels , I hope I get help here . class ConsultationConsumer(ListModelMixin, GenericAsyncAPIConsumer): queryset = Consu…

---

## [Django Channels - Redis Alternatives](https://forum.djangoproject.com/t/django-channels-redis-alternatives/33246)

<div class="topic-metadata">

**Author:** [@aDramaQueen](https://forum.djangoproject.com/u/aDramaQueen)\
**Replies:** 2\
**Last updated:** [November 4, 2024, 12:04am UTC](https://forum.djangoproject.com/t/django-channels-redis-alternatives/33246 "2024-11-04T00:04:30Z")

</div>

Since Redis changed their License model, I am not really keen on using Redis in production any longer. They said, it’s only been done to make Cloud-Providers pay their fees, but in such situations I always rememember Sta…

---

## [self.scope\['user'\] always returns Anonymous User](https://forum.djangoproject.com/t/self-scope-user-always-returns-anonymous-user/17873)

<div class="topic-metadata">

**Author:** [@UG-SEP](https://forum.djangoproject.com/u/UG-SEP)\
**Replies:** 8\
**Last updated:** [November 3, 2024, 12:55am UTC](https://forum.djangoproject.com/t/self-scope-user-always-returns-anonymous-user/17873 "2024-11-03T00:55:59Z")

</div>

self.scope\[‘user’\] always returns Anonymous User even the user is authenticated Middlewares included MIDDLEWARE = \[ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMi…

---

## [Cannot access ForeignKey in acync context](https://forum.djangoproject.com/t/cannot-access-foreignkey-in-acync-context/36087)

<div class="topic-metadata">

**Author:** [@DragonwolfAside](https://forum.djangoproject.com/u/DragonwolfAside)\
**Replies:** 3\
**Last updated:** [November 2, 2024, 11:40am UTC](https://forum.djangoproject.com/t/cannot-access-foreignkey-in-acync-context/36087 "2024-11-02T11:40:21Z")

</div>

I have a swapped User model and I added some other fields such as post\_1 referred to Post Model. account/models.py class CustomUser(AbstractUser): ... post\_1 = models.ForeignKey(Post, on\_delete=models.SET\_NULL,…

---

## [Concerns about Consumer using sync\_to\_async](https://forum.djangoproject.com/t/concerns-about-consumer-using-sync-to-async/36099)

<div class="topic-metadata">

**Author:** [@SimonVitt](https://forum.djangoproject.com/u/SimonVitt)\
**Replies:** 10\
**Last updated:** [October 31, 2024, 4:13pm UTC](https://forum.djangoproject.com/t/concerns-about-consumer-using-sync-to-async/36099 "2024-10-31T16:13:29Z")

</div>

Hello everybody, I stumbled over a default behavior of sync\_to\_async in a AsyncWebsocketConsumer or in general in web sockets, which I find odd and I’m not totally sure how to go on about this. When sync\_to\_async is ca…

---

## [async in templates](https://forum.djangoproject.com/t/async-in-templates/22732)

<div class="topic-metadata">

**Author:** [@plopidou](https://forum.djangoproject.com/u/plopidou)\
**Replies:** 6\
**Last updated:** [October 30, 2024, 9:09pm UTC](https://forum.djangoproject.com/t/async-in-templates/22732 "2024-10-30T21:09:46Z")

</div>

Doc says (Asynchronous support | Django documentation | Django): async for author in Author.objects.filter(name\_\_startswith="A"): book = await author.books.afirst() But a pattern I use often (is that even a pattern…

---

## [Why request.user.is\_authenticated sync?](https://forum.djangoproject.com/t/why-request-user-is-authenticated-sync/35980)

<div class="topic-metadata">

**Author:** [@DragonwolfAside](https://forum.djangoproject.com/u/DragonwolfAside)\
**Replies:** 2\
**Last updated:** [October 28, 2024, 8:51am UTC](https://forum.djangoproject.com/t/why-request-user-is-authenticated-sync/35980 "2024-10-28T08:51:47Z")

</div>

Getting django.core.exceptions.SynchronousOnlyOperation while running: async def index(request): if not request.user.is\_authenticated: return HttpResponseRedirect(reverse('account:login') + f'?next={request.…

[Previous page](https://forum.djangoproject.com/c/users/async-channels/23.md)

[Next page](https://forum.djangoproject.com/c/users/async-channels/23.md?page=2)
