Wednesday, February 22, 2017

Re: django channels in the shell

I would recommend using the channel layer object directly instead in future:

from channels.asgi import get_channel_layer
channel_layer = get_channel_layer()

That will make sure all settings are applied the same.

Andrew

On Wed, Feb 22, 2017 at 8:19 PM, chris rose <chris.rose.one@gmail.com> wrote:
solved it.. I had to explicitly add the hosts parameter

from django.conf import settings
from django.utils.module_loading import import_string

config = getattr(settings, "CHANNEL_LAYERS", {})
hosts = config['default']['CONFIG']['hosts']
backend_class = import_string(config['default']['BACKEND'])
channel_layer = backend_class(hosts=hosts)

channel = channel_layer.group_channels('poll')[0]
channel_layer.send(channel, {"text": "hello world!"})

--
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-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/b4e8cb61-4428-48d6-aeb9-463e21398dfe%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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-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/CAFwN1uqBhrtM%3DLSr-_f68etmvJWRANQwMVCJxPSX1cO17q6DRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment