我想试试多进程node的websocket,我看得 https://socket.io/docs/using-... , 尝试使用redis但是看到最后的三行代码,试着用,但是用pm2多开node进程还是连不上var io = require("socket.io")(3000);var socketRedis = require("socket.io-redis");io.adapter(socketRedis({host: 'localhost', port: 6379}));io.of('/').adapter.on('error', function(err){ console.log("err: " + err);});io.on("connection", function(socket){ console.log("web socket connection successful"); socket.on("disconnect", function(){ console.log("web socket disconnect") }); socket.on("chat message", function(msg){ io.emit("chat message", {msg: [1,2,3,4,5]}); })})redis 数据肯定打开了, 就是握手失败,不用pm2, 就是成功的这个socket.io-redis 到底怎么用啊?
添加回答
举报
0/150
提交
取消