socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

Redis Adapter doesn't seem to be working

Open austinh opened this issue 12 years ago • 7 comments

Ive tried using the redis adapter as specified in the docs in combination with the socket.io-emitter in a different process and while the socket.io-emitter is working, and even redis is receiving data, the actual socket.io server is not picking up any events emitted to it.

Redis is connected, its receiving data, and socket.io-emitter is obviously working or else redis wouldn't receive data in redis-cli monitor

var server = require('http').Server(); var io = require('socket.io')(server); var redis = require('socket.io-redis'); io.adapter(redis({ host: 'localhost', port: 6379 })); server.listen(8080);

that is the code i'm using. Whats wrong?

austinh avatar Jun 05 '14 05:06 austinh

Hi,

Could the socket.io team help the comunity with how to scale a socket.io application on multiple nodes, when stiky sessions are not available?

I am trying to scale a socket.io application, with no success, therefore I forked the sample chat application, here (https://github.com/liviuignat/chat-example-cluster), to try to implement socket.io + redis adapter sample, again with no success.

I actually see no key in redis also. This is also hosted on heroku under http://chat-example-cluster.herokuapp.com/. From what you can see the application has a lot of fails, sometimes it works with no problems, sometimes it fails to connect.

Any help with the "chat-example-cluster" would help a lot the comunity.

Thanks,

liviuignat avatar Oct 01 '14 11:10 liviuignat

I got it working. (This does require sticky sessions) What was confusing (to me) was that the servers don't actually get the events. socket.io redis makes sure that when you broadcast something from one socket.io server instance the clients of all socket.io server instances receive the event. The servers don't receive the events because they're not clients. (You could probably use socket.io-client to also make a server a client).

peteruithoven avatar Oct 02 '14 10:10 peteruithoven

Yes, with sticky sessions enabled it works. Is it any possibility to have it working without any sticky sessions?

liviuignat avatar Oct 02 '14 11:10 liviuignat

Maybe when you disable the polling transport method?

peteruithoven avatar Oct 02 '14 11:10 peteruithoven

If you set the transport method to websocket only, the system will work without sticky session.

StevenRoan avatar Oct 17 '14 13:10 StevenRoan

@liviuignat can you expand on what's not working? AFAIK using the redis-adapter, you need to emit to rooms and not the individual socket instances.

yads avatar Oct 17 '14 16:10 yads

Closing due to inactivity.

rase- avatar Jan 13 '15 02:01 rase-