npm @socket.io/redis-adapter 7.1.0

latest releases: 8.3.0, 8.2.1, 8.2.0...
2 years ago

Features

  • add support for redis v4 (aa681b3)
  • do not emit "error" events anymore (8e5c84f)

Error handling can now be done on the redis clients directly.

Before:

io.of("/").adapter.on("error", () => {
  // ...
});

After:

pubClient.on("error", () => {
  // something went wrong
});

subClient.on("error", () => {
  // something went wrong
});
  • send response to the requesting node only (f66de11)

A more performant way to do request-response is available behind an option, publishOnSpecificResponseChannel:

const io = require('socket.io')(3000);
const { createClient } = require('redis');
const redisAdapter = require('@socket.io/redis-adapter');

const pubClient = createClient({ host: 'localhost', port: 6379 });
const subClient = pubClient.duplicate();
io.adapter(redisAdapter(pubClient, subClient, {
  publishOnSpecificResponseChannel: true
}));

To upgrade an existing deployment, you will need to upgrade all nodes to the latest version with publishOnSpecificResponseChannel = false, and then toggle the option on each node.

Please check the commit for more information.

Links

Don't miss a new redis-adapter release

NewReleases is sending notifications on new releases.