socket.io-redis

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

谁说我不能喝 提交于 2019-12-06 19:01:21
问题 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 disconnect I tried io.of('namespace').connected[socketid] , it only work for current process ( it mean that it can check for current process only). Anyone can help me? Thanks for advance. 回答1: How can I check socket is alive (connected) with socketid I

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

柔情痞子 提交于 2019-12-05 20:21:13
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? Thanks! Dmitry Paranyushkin Found an answer in this question: Socket.io Won't Emit messages to rooms on

Example to use socket.io-redis

天涯浪子 提交于 2019-12-05 17:49:10
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, 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 plugin to your socket.io instances: var express = require('express'); var app = express(); var server = require(

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

孤街浪徒 提交于 2019-12-05 00:16:28
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 disconnect I tried io.of('namespace').connected[socketid] , it only work for current process ( it mean that it can check for current process only). Anyone can help me? Thanks for advance. How can I check socket is alive (connected) with socketid I tried namespace.connected[socketid], it only work for current process. As you said, separate process means

Horizontally scale socket.io with redis

二次信任 提交于 2019-12-03 15:11:28
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? As you wan to scale socket.io server, and you have used nginx as load balancer, do not forget to setup sticky load balancing , othersie single connection will be connected