I'm building a chat application. The user list is stored in redis when clients connect.Here's an example:io.on('connection', function(socket) { var userID = getUserID(socket.handshake.headers.cookie); redis.hset("chat:test", userID); socket.on('disconnect', function() { redis.hdel("chat:test", userID); }); }); I'm using socket-io-redis to connect all of the processes together.I'm not sure how to handle crashes in this case. Let's say one process crashes. All of the users who were connected on that process will remain in the user list that's stored in redis because the disconnect event never fired.One thought I had was that I'd have one master process and all socket.io processes would send the information of all clients who connected / disconnected to the master process.If a worker crashed, the master would remove the users from the user list and handle it just like the worker normally would.I'm not sure if this is the right way to solve this issue, but hopefully someone here can point me in the right direction if it isn'tI'd appreciate any help you guys can give
Submitted June 19, 2018 at 06:03PM by O40dzLttx27cAoekaGBR
No comments:
Post a Comment