socket.io-redis

How to store client associated data in socket.io 1.0

狂风中的少年 提交于 2020-12-29 02:53:45
问题 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; }); }); in case I need multiple nodes? 回答1: Yes, it is OK to add properties to the socket.io socket object. You should be careful to not use names that could conflict with built-in properties or methods (I'd suggest adding a leading underscore or namescoping them with some sort of

How to store client associated data in socket.io 1.0

99封情书 提交于 2020-12-29 02:53:06
问题 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; }); }); in case I need multiple nodes? 回答1: Yes, it is OK to add properties to the socket.io socket object. You should be careful to not use names that could conflict with built-in properties or methods (I'd suggest adding a leading underscore or namescoping them with some sort of

How to store client associated data in socket.io 1.0

隐身守侯 提交于 2020-12-29 02:50:39
问题 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; }); }); in case I need multiple nodes? 回答1: Yes, it is OK to add properties to the socket.io socket object. You should be careful to not use names that could conflict with built-in properties or methods (I'd suggest adding a leading underscore or namescoping them with some sort of

Using socket.io-redis on azure web service

不羁的心 提交于 2019-12-25 04:27:28
问题 Currently I have deployed a node application to azure app service. My current app service plan has two core processor. And I have set nodeProcessCountPerApplication: 2 in iisnode.yml file. Now I have implemented socket.io functionality for real time update to the UI. With single process it works fine. When I use nodeProcessCountPerApplication: 2 problem starts. I am getting the following error- {"code":1,"message":"Session ID unknown"} I tried to solve this using socket.io-redis. Here is the

Example to use socket.io-redis

做~自己de王妃 提交于 2019-12-22 08:07:30
问题 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, 回答1: The socket.io-redis documentation don't mention you actually need to run a redis server so you might have forgotten that. The socket.io-redis plugin uses the pub/sub client of the redis server to connect multiple socket.io instances. download and install a redis server from https://redis.io add the redis

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

我是研究僧i 提交于 2019-12-20 12:23:23
问题 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){ socket.join("CLIENT_1"); }); So I want to get number of clients connected to room "CLIENT_1" , io.sockets.adapter.rooms["CLIENT_1"]; but I only get connection from current process. How can I get connection from all server processes connected through

socket.io client not receiving io.emit from server ( using redis adapter )

百般思念 提交于 2019-12-12 03:18:57
问题 I have a problem which started when updated to 1.4.5 recently. ( This has been working for the last 2 years ) . So when I send a client-msg to the server, the server receives the msg and then is supposed to emit the msg back to all the connected sockets ( including itself ). The problem I am now having is I can no longer emit messages to all the sockets. If I change the io.emit to socket.emit I receive the server-response just fine, but of course, that's only for that one socket. I even went

NodeJS Socket.io Server<-->Server communication

谁说我不能喝 提交于 2019-12-10 18:48:39
问题 I'm trying to establish server to server communication in NodeJS (cluster architecture, separate VMs) with socket.io. I try to use what is posted here http://socket.io/docs/using-multiple-nodes/ var io = require('socket.io')(3000); var redis = require('socket.io-redis'); io.adapter(redis({ host: 'localhost', port: 6379 })); So I assume (probably wrong) that when doing io.emit("message", "some example message") I can listen for it with: io.on('connection', function(socket){ console.log("io.on"

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

空扰寡人 提交于 2019-12-10 10:20:07
问题 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 using socket.broadcast.to(socket.room).emit('chat message', msg); or socket.to(socket.room).emit('chat message', msg); but both only send the message to receivers, but not to the sender. What should I do so that this message also goes to the sender, who's in the chat room as well?

Horizontally scale socket.io with redis

穿精又带淫゛_ 提交于 2019-12-09 13:05:20
问题 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 question is, with socket-io redis module, can I send a message to a specific socket connected to one of the proxy servers from one of the backend servers if they are all connected to the same redis server? If so, how do I do that? 回答1: As you wan to scale socket.io server, and you have used nginx