Re: Django Channels: Model Binding not sending out message to group

22 views
Skip to first unread message

Andrew Godwin

unread,
Dec 13, 2017, 1:44:55 PM12/13/17
to django...@googlegroups.com
Since you double-posted, I will reply to the other thread.

On Wed, Dec 13, 2017 at 12:00 AM, Zac Kwan <weih...@gmail.com> wrote:
I have nginx, uwsgi and asgi setup correctly. With my javascript frontend, it is connected to base on the worker log that contains the demultiplexer response. However, when I try to create a model (via API, admin or shell) it does not send a message to the worker. In `runserver` all work fine.

So I try creating the model in python manage.py shell.

$ python manage.py shell


Python 3.5.1 (v3.5.1:37a07cee5969, Dec  5 2015, 21:12:44)


[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin


Type "help", "copyright", "credits" or "license" for more information.


(InteractiveConsole)
>>> from project.models import Feed

>>> from channels import Group

>>>
>>> Feed.objects.create(name="a1") #This does not send a message to my frontend
>>>
>>>
Group('dsadsa').send({"text": "hi"}) # somehow, after doing this no matter which group I send to, it will start working in shell.

>>>
>>> Feed.objects.create(name="a99") #Now when i do this again, it work. My frontend receive a message
 



I not really sure what I did wrong or is it a bug with Django Channels. There is no logs message about binding message being send out by the worker even when I do it successfully in the shell. 

Somehow, I find out that after I try to send a Group message to any group, creating the Feed again will sends out the message correctly.

The following is my code for connecting to redis:
CHANNEL_LAYERS = {
   "default": {
       "BACKEND": "asgi_redis.RedisChannelLayer",
       "CONFIG": {
           "hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')],
       },
       "ROUTING": "github_hook.routing.channel_routing",
   },
}

Any kind soul know what is the problem? Am I missing something that's why binding does not work in production?

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django...@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/17cbdbbe-731f-4349-b3a7-874f4faded8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages