Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django-websocker error: ValueError: message object is not of type RedisMessage #242

Open
sam-thecoder opened this issue Aug 20, 2017 · 1 comment

Comments

@sam-thecoder
Copy link

I'm learning how to setup django-websocket with redis https://django-websocket-redis.readthedocs.io/en/latest/api.html#use-redispublisher-from-inside-django-views and I'm calling it like this

message =  "Percentage {0}% \t {1}/{2} \t {3}".format(percentage, counter, (width * height), delta)
print message
socket = RenderView()
socket.get(request, message)

in the view

from django.views.generic.base import View
from ws4redis.publisher import RedisPublisher

class RenderView(View):
    facility = 'render-view'
    audience = {'broadcast': True}

    def __init__(self, *args, **kwargs):
        super(RenderView, self).__init__(*args, **kwargs)
        self.redis_publisher = RedisPublisher(facility=self.facility, **self.audience)

    def get(self, request, message):
        self.redis_publisher.publish_message(message)

I'm getting this error

    socket.get(request, message)
  File "/home/samuel/Documents/code/revamp/gallery/socket.py", line 13, in get
    self.redis_publisher.publish_message(message)
  File "/usr/local/lib/python2.7/dist-packages/ws4redis/redis_store.py", line 110, in publish_message
    raise ValueError('message object is not of type RedisMessage')
ValueError: message object is not of type RedisMessage
@erikreed
Copy link
Contributor

You just need to wrap your message in RedisMessage.

E.g.

message = RedisMessage('data')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants