Questions tagged [socket.io-redis]

Adapter to enable broadcasting of events to multiple separate socket.io server nodes.

By running socket.io with the socket.io-redis adapter you can run multiple socket.io instances in different processes or servers that can all broadcast and emit events to and from each other.

If you need to emit events to socket.io instances from a non-socket.io process, you should use socket.io-emitter.

See also

Installing:

$ npm install socket.io
112 questions
22
votes
2 answers

How to store client associated data in socket.io 1.0

The docs say socket.io doesn't support .get .set now Is it okay to store client associated data like io.sockets.on('connection', function (client) { client.on('data', function (somedata) { client['data'] = somedata; }); …
Herokiller
  • 2,891
  • 5
  • 32
  • 50
19
votes
2 answers

Example to use socket.io-redis

Hi all and thanks for your time and your help. I need a simple example for use socket.io-redis, with comments please. I read the documentation, but I did not understand. Thank you,
Rifton007
  • 291
  • 1
  • 5
  • 24
17
votes
4 answers

Socket.io: How to count clients in a room with Socket.io-redis adapter

I start building chat server using Socket.io with multiple nodes. It uses Socket.io-redis to connect all servers together and rooms for messaging. When a client connects with server I join client to some room. io.on('connection', function(socket){ …
Phatthana Batt
  • 356
  • 3
  • 13
15
votes
4 answers

How to check socket is alive (connected) in socket.io with multiple nodes and socket.io-redis

I am using socket.io with multiple nodes, socket.io-redis and nginx. I follow this guide: http://socket.io/docs/using-multiple-nodes/ I am trying to do: At a function (server site), I want to query by socketid that this socket is connected or…
John Nguyen
  • 711
  • 6
  • 21
7
votes
2 answers

Horizontally scale socket.io with redis

I currently am creating a horizontally scalable socket.io server which looks like the following: LoadBalancer (nginx) Proxy1 Proxy2 Proxy3 Proxy{N} BackEnd1 BackEnd2 BackEnd3 BackEnd4 BackEnd{N} My…
Steve P
  • 319
  • 3
  • 7
6
votes
1 answer

Socket.IO - how to emit event to everybody in the room, including sender?

In my Socket.Io / Node.Js / Express app - before I added chat room – I used to emit events like this for everyone (including the sender): io.emit('chat message', msg); Now I added rooms and try to do the same thing…
Aerodynamika
  • 7,883
  • 16
  • 78
  • 137
6
votes
0 answers

Socket.IO checking if room contains clients with socket.io-redis

What is "efficient way" to check if some room has connected clients or even exists? socket.on('pm', function(data) { data.from = socket.decoded_token._id; var to = data.to; if (_.isUndefined(io.sockets.adapter.rooms[to])) { …
Danil
  • 2,497
  • 2
  • 19
  • 27
5
votes
2 answers

Laravel Echo Server, Redis, Socket.IO: Can't seem to make them work

I'm developing real-time app with Laravel. Since I don't want to use Pusher, I'm trying to make websockets work using Laravel Echo Server, Redis, and Socket.IO. However, I'm having a problem with this stack. The client (browser) can't seem to…
Kolokoy
  • 118
  • 1
  • 5
5
votes
0 answers

listening to a socket with socket.io-redis module

With socket.io-redis module we can easily emit/broadcast message with saved-socket-id. io.to(socket-id-from-redis).emit('serverEvent', "some message"); On the otherhand, what's the best way for listening to the socket with out any extra/external…
Cem Ozturk
  • 51
  • 2
4
votes
1 answer

remoteDisconnect socket.io and redis

I'm trying to implement socket.io with Redis adapter in NodeJs. Mostly it works, but sometimes I am still getting errors when trying to disconnect / connect sockets, so I think I haven't implement it correctly. Could someone please explain what is…
Miha Trtnik
  • 236
  • 1
  • 3
  • 8
4
votes
0 answers

Using socket.io-redis & multiple servers/processes. How do I send a message to a specific socket ID with a callback?

I have multiple processes & servers, and am using socket.io-redis with session affinity (on Heroku). When a client connects, I store a map of the client's user ID to the client's socket ID in Redis. Upon disconnecting, I delete the client's user ID…
Ismail Khan
  • 842
  • 2
  • 8
  • 20
4
votes
1 answer

Scaling to 2+ dynos on Heroku with socket.io-redis and RedisToGo

I'm trying to use socket.io-redis to scale my app on Heroku to 2 dynos (or more). Here is my code (where config.redis is just an object housing RedisToGo port, host, and pass values): var redisApp = require('redis'); var redis =…
3
votes
1 answer

How to have two backend nodejs servers communicate with each other to handle different tasks with k8s in mind

I have an express server that handles all authentication(using token auth and have redis store sessions to control the amount of logins per device) and reading/writing to mongoDB. I want to add chat for my users(using socket.io and socket.io-redis)…
mitchldtn
  • 423
  • 1
  • 4
  • 18
3
votes
1 answer

How to handle socketio on multiple nodes if a node is down

I am trying to set up socketio on multiple nodes for load balancing between them. I came up with something like this in socketio docs: Using multiple nodes. It does the work perfectly for event passing through redis between multiple nodes, but the…
3
votes
0 answers

Delay in getting messages to Socket in node js server

When I send a message from client, It is taking around 6 to 10 seconds to reach the server. Lets say the time when i send the message is at 07:30:10 It is receiving at 07:30:16 in the node server. Please help me to findout the reason behind that. I…
1
2 3 4 5 6 7 8