In production, I have setup asgi, wsgi and nginx. My javascript frontend manage connected successfully base on the logs in runworker. However, when a new model is created (DRF API, Admin or Shell), it does not send a message to the group where my frontend is connected. It work perfectly in runserver.
I had did some testing in the python manage.py shell and found out that it work when I try to send a group message myself first. $ python manage.py shell Python 3.6.2 (default, Aug 27 2017, 18:32:19) [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from channels import Group >>> from github_hook.models import Feed >>> >>> Feed.objects.create(name="foo") # Model is created but frontend did not receive any message >>> >>> Group("news").send({"text": "dsa"}) # After I do this, a print I had in consumers.py happened >>> consumers.py is run! >>> >>> Feed.objects.create(name="foo") # Now when i created a new object, frontend successfully received the mssage The following is my CHANNEL_LAYERS setup: CHANNEL_LAYERS = { "default": { "BACKEND": "asgi_redis.RedisChannelLayer", "CONFIG": { "hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')], }, "ROUTING": "github_hook.routing.channel_routing", }, } I had been on this for 2 weeks, still caa't figure out what is wrong. Can anyone help me figure out whats wrong? It seems to me that my application that is served by WSGI, when created a model via admin, it does not trigger the message sending. It seems to be missing some init on consumers.py? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/eafc6aa0-d620-4e2a-af22-a715845fb463%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.