node.js - Scaling Socket.IO across multiple servers -


i've been searching around looking on setting multi-server cluster node.js socket.io install. trying do:

  • have 1 vip in f5 loadbalancer, pointing n number of node servers running express, , socket.io
  • have client connect 1 vip via io.connect , have filter 1 of servers behind loadbalancer.
  • when message emitted on 1 of servers, is sent users listening event , connect via other servers.

for example - if have server a, server b , server c behind lb1 (f5), , user connected server a, user b connected server b , user c connected server c.

in "chat" scenario - if message emitted server message event - server b , c should send message connected client. read possible using socket-io.redis, needs redis box - server should install on? if servers connected same redis box - work automatically?

var io = require('socket.io')(server); var redis = require('socket.io-redis'); io.adapter(redis({ host: 'localhost', port: 6379 })); 

any appreciated thanks!

the answer question must set single redis server either outside socketio cluster - , have nodes connect it.

then add @ top of code , works magically without issues.

var io = require('socket.io')(server); var redis = require('socket.io-redis'); io.adapter(redis({ host: 'localhost', port: 6379 })); 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -