
Company News
Socket Has Acquired Secure Annex
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.
@socket.io/redis-adapter
Advanced tools
The Socket.IO Redis adapter, allowing to broadcast events between several Socket.IO servers
The @socket.io/redis-adapter package allows broadcasting packets between multiple Socket.IO servers.
Table of contents
| Feature | socket.io version | Support |
|---|---|---|
| Socket management | 4.0.0 | :white_check_mark: YES (since version 6.1.0) |
| Inter-server communication | 4.1.0 | :white_check_mark: YES (since version 7.0.0) |
| Broadcast with acknowledgements | 4.5.0 | :white_check_mark: YES (since version 7.2.0) |
| Connection state recovery | 4.6.0 | :x: NO |
npm install @socket.io/redis-adapter
| Redis Adapter version | Socket.IO server version |
|---|---|
| 4.x | 1.x |
| 5.x | 2.x |
| 6.0.x | 3.x |
| 6.1.x | 4.x |
| 7.x and above | 4.3.1 and above |
redis packageimport { createClient } from "redis";
import { Server } from "socket.io";
import { createAdapter } from "@socket.io/redis-adapter";
const pubClient = createClient({ url: "redis://localhost:6379" });
const subClient = pubClient.duplicate();
await Promise.all([
pubClient.connect(),
subClient.connect()
]);
const io = new Server({
adapter: createAdapter(pubClient, subClient)
});
io.listen(3000);
redis package and a Redis clusterimport { createCluster } from "redis";
import { Server } from "socket.io";
import { createAdapter } from "@socket.io/redis-adapter";
const pubClient = createCluster({
rootNodes: [
{
url: "redis://localhost:7000",
},
{
url: "redis://localhost:7001",
},
{
url: "redis://localhost:7002",
},
],
});
const subClient = pubClient.duplicate();
await Promise.all([
pubClient.connect(),
subClient.connect()
]);
const io = new Server({
adapter: createAdapter(pubClient, subClient)
});
io.listen(3000);
ioredis packageimport { Redis } from "ioredis";
import { Server } from "socket.io";
import { createAdapter } from "@socket.io/redis-adapter";
const pubClient = new Redis();
const subClient = pubClient.duplicate();
const io = new Server({
adapter: createAdapter(pubClient, subClient)
});
io.listen(3000);
ioredis package and a Redis clusterimport { Cluster } from "ioredis";
import { Server } from "socket.io";
import { createAdapter } from "@socket.io/redis-adapter";
const pubClient = new Cluster([
{
host: "localhost",
port: 7000,
},
{
host: "localhost",
port: 7001,
},
{
host: "localhost",
port: 7002,
},
]);
const subClient = pubClient.duplicate();
const io = new Server({
adapter: createAdapter(pubClient, subClient)
});
io.listen(3000);
Sharded Pub/Sub was introduced in Redis 7.0 in order to help scaling the usage of Pub/Sub in cluster mode.
Reference: https://redis.io/docs/interact/pubsub/#sharded-pubsub
A dedicated adapter can be created with the createShardedAdapter() method:
import { Server } from "socket.io";
import { createClient } from "redis";
import { createShardedAdapter } from "@socket.io/redis-adapter";
const pubClient = createClient({ host: "localhost", port: 6379 });
const subClient = pubClient.duplicate();
await Promise.all([
pubClient.connect(),
subClient.connect()
]);
const io = new Server({
adapter: createShardedAdapter(pubClient, subClient)
});
io.listen(3000);
Minimum requirements:
redis@4.6.0Note: it is not currently possible to use the sharded adapter with the ioredis package and a Redis cluster (reference).
| Name | Description | Default value |
|---|---|---|
key | The prefix for the Redis Pub/Sub channels. | socket.io |
requestsTimeout | After this timeout the adapter will stop waiting from responses to request. | 5_000 |
publishOnSpecificResponseChannel | Whether to publish a response to the channel specific to the requesting node. | false |
parser | The parser to use for encoding and decoding messages sent to Redis. | - |
| Name | Description | Default value |
|---|---|---|
channelPrefix | The prefix for the Redis Pub/Sub channels. | socket.io |
subscriptionMode | The subscription mode impacts the number of Redis Pub/Sub channels used by the adapter. | dynamic |
socket.io-emitter is a package that allows you to send events to Socket.IO servers from non-Socket.IO processes. It uses Redis to communicate with the Socket.IO servers, similar to @socket.io/redis-adapter, but is designed for external processes rather than internal server-to-server communication.
socket.io-redis is another adapter for Socket.IO that uses Redis Pub/Sub to enable horizontal scaling. It is very similar to @socket.io/redis-adapter, but @socket.io/redis-adapter is the more modern and actively maintained version.
FAQs
The Socket.IO Redis adapter, allowing to broadcast events between several Socket.IO servers
The npm package @socket.io/redis-adapter receives a total of 763,865 weekly downloads. As such, @socket.io/redis-adapter popularity was classified as popular.
We found that @socket.io/redis-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.

Research
/Security News
Socket is tracking cloned Open VSX extensions tied to GlassWorm, with several updated from benign-looking sleepers into malware delivery vehicles.

Product
Reachability analysis for PHP is now available in experimental, helping teams identify which vulnerabilities are actually exploitable.