Comments (7)
I created a redis pub/sub wrapper with a callback system. This allows me to, from one instance, execute a emit on another instance and retrieve the response using a callback.
https://www.npmjs.org/package/redis-pubsubber
from socket.io-redis-adapter.
If you need to emit events to socket.io instances from a non-socket.io process, you should use socket.io-emitter.
from socket.io-redis-adapter.
Thanks I'll have a look at that, maybe there is a workaround there.
But I'm actually in the situation where I use a clustered socket.io server. Now I would like to forward a message from one client (that's for example on instance A) to a specific other client (that's for example on instance B). So all instances are socket.io servers.
from socket.io-redis-adapter.
Use rooms, and send the message to the room with the client you desire.
Every client gets its own room with a unique id. So, sending it just to the
room with the id would work.
Regards,
Shantanu Thatte
On Oct 1, 2014 4:24 PM, "Peter Uithoven" [email protected] wrote:
Thanks I'll have a look at that, maybe there is a workaround there.
But I'm actually in the situation where I use a clustered socket.io
server. Now I would like to forward a message from one client (that's for
example on instance A) to a specific other client (that's for example on
instance B). So all instances are socket.io servers.—
Reply to this email directly or view it on GitHub
#30 (comment)
.
from socket.io-redis-adapter.
I'll try.
I'm sorry I forgot to mention that I would like to use acknowledgment callbacks. I tried putting the target client into a room with a custom name (so I don't have to store the socket.io id in a database), but then it becomes a broadcast (to possible multiple clients) and then I can't specify a acknowledgment callback. So I tried retrieving the clients from a room, so I could target them specifically, but retrieving the clients from rooms isn't possible yet (#13).
from socket.io-redis-adapter.
I just want to confirm that talking to a client of another socket.io server can be done by using their socket.io id as room name. It also works when you put this target client in a custom room with a fixed name and talk to that room from another socket.io server instance.
This means that socket.io-redis does support rooms, it just can't list the clients in rooms. It probably can't list the rooms that exist in other servers either.
But sadly, emitting into a room is considered broadcasting, probably because there can be multiple clients in a room, so you can't use callbacks. You'll get the following error when trying:
Callbacks are not supported when broadcasting
from socket.io-redis-adapter.
So I see two possible solutions:
- Find a way to create a fake socket (so I can use existing callback code)
- Broadcast to a room and build my own callback system, see: socketio/socket.io#1656 (comment)
from socket.io-redis-adapter.
Related Issues (20)
- How scalable is the redis pub/sub approach? HOT 8
- Does this work with ioredis-mock? HOT 1
- redisClient.send_command is not a function HOT 1
- UnhandledPromiseRejection when trying to add a RedisAdapter to socketIO
- Consult about a logic problem in the code
- Retrieving number of connected sockets using `fetchSockets` without getting all socket information HOT 5
- Make subscription client optional HOT 1
- Proper way to use this adapter with ioredis HOT 2
- Feature request: limit nodes hit by "serverSideEmit" and "fetchSockets" in sharded adapter
- Error on websocket multi instance using redis-adapter HOT 1
- This.io.sockets.adapter.pubClient.isReady becomes false and is never ready again HOT 2
- Error: 23984 trailing bytes HOT 5
- dynamic subscription mode breaks remote socket.emit() HOT 3
- [email protected]: timeout reached while waiting for fetchSockets response
- MaxListenersExceededWarning due to SSUBSCRIBE/SUNSUBSCRIBE memory leak HOT 2
- the below error occurs when the user disconnect from the socket HOT 1
- the below error occurs when the user disconnect from the socket HOT 1
- Socket.io adapter HOT 1
- TypeError with @socket.io/redis-adapter on Node.js v18.15.0 HOT 5
- Lot of "ignoring unknown request" in Debug HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socket.io-redis-adapter.