Socket.io, Redis Store and IE

2019-04-14 14:22发布

问题:

I got a game using Redis, Socket.io, theres 2 nodejs servers running diff socket.io clients. I am communicating with both socket.io clients through the redis store, that way I can emit to all sockets whenever I want. And it works.

io.sockets.emit('successful_connection', { success : true }); return;

My problem is, when ie calling a specific socket by id, it fails.

io.sockets.socket(socketId).emit('successful_connection', { success : true }); return;

I have no idea why, it works in all other browsers. Heres the code for socket.io/redis store config

    io.configure(function(){
        var RedisStore = require('socket.io').RedisStore,
            opts = {host: **.***.**.**, port: ****};
        io.set('store', new RedisStore({redisPub:opts, redisSub:opts, redisClient:opts}));
    });     

Any advice would be helpful, right now my main thought is "why have nodejs/socket.io servers." Is there really a benefit if i have to deal with this. Thanks

回答1:

This blog post with example code might help you.