Is anyone using sentinel for auto failover with a RedisStore?

192 views
Skip to first unread message

Ryan Curtis

unread,
Jun 21, 2013, 9:30:35 AM6/21/13
to sock...@googlegroups.com
In theory, the redis-sentinel package should be perfect.  I have 3 socketio servers, each running sentinel and each running redis. the 2nd and 3rd are slaves of the first.  This is my setup logic, in coffeescript:

@server = require('http').createServer(@app)
@io = socketio.listen @server
# @io.set 'log level', 0

sentinel = Sentinel {host:'localhost':, port:26379}
clients = {}
clients.write = sentinel.createClient('mymaster', {role:'master'})
clients.pub   = sentinel.createClient('mymaster', {role:'master'})
clients.sub   = sentinel.createClient('mymaster', {role:'master'})
for key, client of clients
client.on 'error', (e) =>
logError 'realtime redis error', e

@io.set 'store', new socketio.RedisStore 
redisClient: clients.write
redisPub:    clients.pub
redisSub:    clients.sub

I'm using a namespace of /realtime and rooms, so my broadcast looks like @io.of('/realtime').in(room).emit('event', message)

Note that, for any client connected to any server, broadcasts from the server are received fine, and I'm able to write to redis without any issues using this setup, but broadcasts from other servers are not pubsubbed across to the client.

Does anyone see any problems with this or have suggestions?

Ryan Curtis

unread,
Jun 21, 2013, 1:13:58 PM6/21/13
to sock...@googlegroups.com
I found the answer!  This issue is that socket.io doesn't use the latest redis, and when using the RedisStore the first thing it does with the provided clients is check to see if they are instanceof redis.RedisStore.  The solution is to pass in the version of redis used by redis-sentinel:

@io.set 'store', new socketio.RedisStore 
redis: require 'redis'
redisClient: clients.write
redisPub:    clients.pub
redisSub:    clients.sub



Reply all
Reply to author
Forward
0 new messages