Reputation: 46208
I'm trying to use websockets with Django for small parts of my application.
Trying the first example to broadcast a message with django-websocket-redis
from ws4redis.publisher import RedisPublisher
redis_publisher = RedisPublisher(facility='foobar', broadcast=True)
redis_publisher.publish_message('Hello World')
I'm actually receiving the message into subscribed clients but I'm getting this error:
wrong number of arguments for 'set' command [...] Exception location my_virtualenv/local/lib/python2.7/site-packages/redis/connection.py in read_response, line 344
(traced from the publish_message()
call)
My versions:
Django==1.6.2
django-websocket-redis==0.4.0
redis==2.9.1
Can someone help me to debug that ?
Upvotes: 2
Views: 5593
Reputation: 46208
I finally set the expiration time to 0 as a workaround
WS4REDIS_EXPIRE = 0
This prevents ws4redis to store anything in redis.
Fixed since 0.4.1
Upvotes: 1
Reputation: 2131
Looks like it's a bug.
Fix:
in ws4redis.redis_store.RedisStore
in publish_message
, change
self._connection.set(channel, message, ex=expire)
to
self._connection.setex(channel, expire, message)
the redis SET
command does not take a 3rd argument. What I believe was meant was to set a value that expires after a number of seconds, which is the redis SETEX
command. The py-redis setex
method is called like setex(name, time, value)
.
This resolves the "Wrong number of argument for 'set'" error.
ref: https://github.com/jrief/django-websocket-redis/pull/30
Upvotes: 2