Ir para o conteúdo principal

Redis Adapter v6.0.0

· 2 minutes de lecture
Damien Arrachequesne

Following the release of Socket.IO v3.0.0, the Redis Adapter was updated and a new release is out: 6.0.0

For reference, the Redis Adapter is used when broadcasting packets across a set of Socket.IO servers. It relies on Redis Pub/Sub mechanism.

More information about how it works:

The release notes can be found here:

Please note that the new release is not compatible with Socket.IO v2, and previous versions are not compatible with Socket.IO v3 (compatibility table).

Notable changes

All the requests (for inter-node communication) now return a Promise instead of accepting a callback

The Redis Adapter exposes additional methods for managing sockets and rooms in a multi-node setup:

  • RedisAdapter.sockets(): returns the list of Socket IDs
  • RedisAdapter.allRooms(): returns the list of all rooms.
  • RedisAdapter.remoteJoin(id, room): make the socket join the room
  • RedisAdapter.remoteLeave(id, room): make the socket leave the room
  • RedisAdapter.remoteDisconnect(id, close): disconnect the socket with the given id

Those methods used to accept a callback argument, they will now return a Promise.


io.of('/').adapter.allRooms((err, rooms) => {
console.log(rooms); // an array containing all rooms (across all nodes)


const rooms = await io.of('/').adapter.allRooms();
console.log(rooms); // a Set containing all rooms (across all nodes)

customHook and customRequest methods were removed

Those methods will be replaced by a more intuitive API in a future iteration.