'What is the difference between Socket.io Redis adapter and Redis emitter
While I'm reading this article from the Socket.io documentation
I found that the following two packages @socket.io/redis-adapter and @socket.io/redis-emitter are used to emit data to the clients that are on the other servers.
Are these two packages different? And if yes what is the difference? And when to use one instead of the other?
Solution 1:[1]
The short answer from Damien — a core committer of Socket.io
The adapter is a component inside the Socket.IO server, while the emitter can be used in another process/service.
And there are two diagrams in the documentation explaining the duties of each package
The long answer
They are pretty similar with the following two differences:
@socket.io/redis-adapter
- Must be linked with a
socket.ioserver, And you must provide it a publish and subscribe redis client. like the following:
io.adapter(createAdapter(pubClient, subClient))
- Responsible to send/receive
socket.iocommands to/from other servers.
@socket.io/redis-emitter
- Can't be linked with a
socket.ioserver, And you must provide it a publish redis client. like the following:
const emitter = new Emitter(pubClient);
- Responsible only to send
socket.iocommands to the other servers (that has@socket.io/redis-adapteradapter with the same redis database connection and channel key configuration)
Note: These differences applies to all socket.io adapters and emitters (e.g. @socket.io/mongo-adapter and @socket.io/mongo-emitter)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
