关于socket.io 负载均衡问题,参考官网Using multiple nodes:http://socket.io/docs/using-multiple-nodes/, 我设置如下:
var io = require('socket.io').listen(8891);
var port=6379;
var host='localhost';
var pwd = '******';
var redis = require('redis').createClient;
var adapter = require('socket.io-redis');
var pub = redis(port, host, { auth_pass: pwd });
var sub = redis(port, host, { detect_buffers: true, auth_pass: pwd });
io.adapter(adapter({ pubClient: pub, subClient: sub }));
关于这个adapter
总是报错:
io.adapter(adapter({ pubClient: pub, subClient: sub }));
^
TypeError: undefined is not a function
at Object.<anonymous> (/home/team/project/ylx/sync-svc/sync-server_8891.js:18:4)
at Module._compile (module.js:462:26)
at Object.Module._extensions..js (module.js:480:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:503:10)
at startup (node.js:132:16)
at node.js:817:3
我的socket.io版本0.9.17,其他版本见下方:
├─┬ [email protected]
│ ├── [email protected]
│ └── [email protected]
├── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ └── [email protected]
└─┬ [email protected]
├── [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
│ ├── [email protected]
│ └── [email protected]
├── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
└── [email protected]
对于此类问题求解决方案~
1
BeginMan OP 刚才测试了下,还是版本的问题。
|