我需要socket.io在负载均衡器后面工作。我知道,这是一个常见的问题。我实施了:
var io = require('socket.io').listen(app.listen(cfg.port, function() {
cfg.logger.info("Express Server listening on "+cfg.port+" for env "+cfg.environment);
}));
var adapter = require('socket.io-redis');
var pubClient = redis.createClient(cfg.redisPort, cfg.redisHost, {auth_pass: cfg.redisPW, return_buffers: true});
var subClient = redis.createClient(cfg.redisPort, cfg.redisHost, {auth_pass: cfg.redisPW, return_buffers: true});
io.adapter(adapter({pubClient: pubClient, subClient: subClient}));
这似乎可以很好地连接到我的redis商店。我想我的问题是,为了让socket.io能够与负载均衡器配合使用,是否需要实现这一切?我怎样才能测试这是否与Elastic Beanstalk一起正常工作?