Gathering detailed insights and metrics for @socket.io/redis-streams-adapter
Gathering detailed insights and metrics for @socket.io/redis-streams-adapter
Gathering detailed insights and metrics for @socket.io/redis-streams-adapter
Gathering detailed insights and metrics for @socket.io/redis-streams-adapter
The Socket.IO adapter based on Redis Streams, allowing to broadcast events between several Socket.IO servers.
npm install @socket.io/redis-streams-adapter
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
30 Stars
26 Commits
15 Forks
5 Watching
1 Branches
4 Contributors
Updated on 29 Oct 2024
Minified
Minified + Gzipped
TypeScript (100%)
Cumulative downloads
Total Downloads
Last day
10.5%
2,791
Compared to previous day
Last week
9.5%
13,651
Compared to previous week
Last month
15.5%
52,941
Compared to previous month
Last year
1,273.5%
708,639
Compared to previous year
2
1
The @socket.io/redis-streams-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 0.1.0 ) |
Inter-server communication | 4.1.0 | :white_check_mark: YES (since version 0.1.0 ) |
Broadcast with acknowledgements | 4.5.0 | :white_check_mark: YES (since version 0.1.0 ) |
Connection state recovery | 4.6.0 | :white_check_mark: YES (since version 0.1.0 ) |
npm install @socket.io/redis-streams-adapter redis
redis
package1import { createClient } from "redis"; 2import { Server } from "socket.io"; 3import { createAdapter } from "@socket.io/redis-streams-adapter"; 4 5const redisClient = createClient({ url: "redis://localhost:6379" }); 6 7await redisClient.connect(); 8 9const io = new Server({ 10 adapter: createAdapter(redisClient) 11}); 12 13io.listen(3000);
redis
package and a Redis cluster1import { createCluster } from "redis"; 2import { Server } from "socket.io"; 3import { createAdapter } from "@socket.io/redis-streams-adapter"; 4 5const redisClient = createCluster({ 6 rootNodes: [ 7 { 8 url: "redis://localhost:7000", 9 }, 10 { 11 url: "redis://localhost:7001", 12 }, 13 { 14 url: "redis://localhost:7002", 15 }, 16 ], 17}); 18 19await redisClient.connect(); 20 21const io = new Server({ 22 adapter: createAdapter(redisClient) 23}); 24 25io.listen(3000);
ioredis
package1import { Redis } from "ioredis"; 2import { Server } from "socket.io"; 3import { createAdapter } from "@socket.io/redis-streams-adapter"; 4 5const redisClient = new Redis(); 6 7const io = new Server({ 8 adapter: createAdapter(redisClient) 9}); 10 11io.listen(3000);
ioredis
package and a Redis cluster1import { Cluster } from "ioredis"; 2import { Server } from "socket.io"; 3import { createAdapter } from "@socket.io/redis-streams-adapter"; 4 5const redisClient = new Cluster([ 6 { 7 host: "localhost", 8 port: 7000, 9 }, 10 { 11 host: "localhost", 12 port: 7001, 13 }, 14 { 15 host: "localhost", 16 port: 7002, 17 }, 18]); 19 20const io = new Server({ 21 adapter: createAdapter(redisClient) 22}); 23 24io.listen(3000);
Name | Description | Default value |
---|---|---|
streamName | The name of the Redis stream. | socket.io |
maxLen | The maximum size of the stream. Almost exact trimming (~) is used. | 10_000 |
readCount | The number of elements to fetch per XREAD call. | 100 |
sessionKeyPrefix | The prefix of the key used to store the Socket.IO session, when the connection state recovery feature is enabled. | sio:session: |
heartbeatInterval | The number of ms between two heartbeats. | 5_000 |
heartbeatTimeout | The number of ms without heartbeat before we consider a node down. | 10_000 |
The adapter will use a Redis stream to forward events between the Socket.IO servers.
Notes:
maxLen
option allows to limit the size of the streamNo vulnerabilities found.
No security vulnerabilities found.