node.jssocketsredissocket.io-redis

Mutliple nodejs server communicating with each other with socket.io-redis not receiving event


I managed to connect two nodejs server to Redis using socket.io-redis. Using "redis-cli monitor" I can see events being received on Redis butit dosent go all the way. It is like I'm missing something.

here how both server look like (with the numbers 1 and 2 being reversed)

socket.on('action', function(data) {
    socket.broadcast.to(3).emit('toServer1', "message from server 2")
})    
socket.on('toServer2', function(msg) {
    console.log('msg', msg)
})

And here is what I see on Redis monitor when the event action is triggered with a button.

1455886600.760190 [0 127.0.0.1:53659] "publish" "socket.io#/wallo#3#" "\x93\xa6zCLzS6\x83\xa4type\x02\xa4data\x92\xa9toServer2\xb5message from server 1\xa3nsp\xa6/wallo\x83\xa6except\x91\xbb/wallo#zWTx7XX3IWTwyAkgAAAD\xa5rooms\x91\x03\xa5flags\x81\xa9broadcast\xc3"

1455886611.012510 [0 127.0.0.1:53692] "publish" "socket.io#/wallo#3#" "\x93\xa602LA0x\x83\xa4type\x02\xa4data\x92\xa9toServer1\xb5message from server 2\xa3nsp\xa6/wallo\x83\xa6except\x91\xbb/wallo#Ta740dOp_limABWNAAAC\xa5rooms\x91\x03\xa5flags\x81\xa9broadcast\xc3"

They both also subscribe to the right channels as well:

1455886848.742998 [0 127.0.0.1:53660] "subscribe" "socket.io#/#/#7xqLUZmHRYvy63akAAAH#"
1455886848.767710 [0 127.0.0.1:53660] "subscribe" "socket.io#/wallo#/wallo#7xqLUZmHRYvy63akAAAH#"
1455886848.809907 [0 127.0.0.1:53660] "subscribe" "socket.io#/wallo#3#"

1455886843.924659 [0 127.0.0.1:53693] "subscribe" "socket.io#/#/#7PFZsIfHabXD9rKnAAAD#"
1455886843.946771 [0 127.0.0.1:53693] "subscribe" "socket.io#/wallo#/wallo#7PFZsIfHabXD9rKnAAAD#"
1455886843.960910 [0 127.0.0.1:53693] "subscribe" "socket.io#/wallo#3#"

Am i missing something. Is there something else it has to do to fetch/receive the events from redis?


Solution

  • Okay... I figured it out.

    I'm suppose to catch the event on the client side and not the server side. I don't know if previous versions of socket.io-redis was different but for some reason I have memory of receiving the event on the server.