{"_id":"@cocalc/redis-streams-adapter","name":"@cocalc/redis-streams-adapter","dist-tags":{"latest":"0.2.3"},"versions":{"0.2.3":{"name":"@cocalc/redis-streams-adapter","version":"0.2.3","description":"The Socket.IO adapter based on Redis Streams, allowing to broadcast events between several Socket.IO servers. (CoCalc fork.)","license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/socketio/socket.io-redis-streams-adapter.git"},"main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"compile":"rimraf ./dist && tsc","format:check":"prettier --parser typescript --check \"lib/**/*.ts\" \"test/**/*.ts\"","format:fix":"prettier --parser typescript --write \"lib/**/*.ts\" \"test/**/*.ts\"","prepack":"npm run compile","test":"npm run format:check && npm run compile && npm run test:redis-standalone && npm run test:redis-cluster && npm run test:ioredis-standalone && npm run test:ioredis-cluster && npm run test:valkey-standalone","test:redis-standalone":"nyc mocha --require ts-node/register test/**/*.ts","test:redis-cluster":"cross-env REDIS_CLUSTER=1 mocha --require ts-node/register test/**/*.ts","test:ioredis-standalone":"cross-env REDIS_LIB=ioredis mocha --require ts-node/register test/**/*.ts","test:ioredis-cluster":"cross-env REDIS_LIB=ioredis REDIS_CLUSTER=1 mocha --require ts-node/register test/**/*.ts","test:valkey-standalone":"cross-env VALKEY=1 mocha --require ts-node/register test/**/*.ts"},"prettier":{"endOfLine":"auto"},"dependencies":{"@msgpack/msgpack":"~2.8.0","debug":"~4.3.1"},"peerDependencies":{"socket.io-adapter":"^2.5.4"},"devDependencies":{"@types/expect.js":"^0.3.29","@types/mocha":"^8.2.1","@types/node":"^18.15.11","cross-env":"7.0.3","expect.js":"0.3.1","ioredis":"^5.3.2","mocha":"^10.1.0","nyc":"^15.1.0","prettier":"^2.8.7","redis":"^4.6.5","rimraf":"^5.0.5","socket.io":"^4.6.1","socket.io-client":"^4.6.1","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{"node":">=14.0.0"},"keywords":["socket.io","redis","adapter"],"_id":"@cocalc/redis-streams-adapter@0.2.3","gitHead":"48666105596d2c19e54113b02704085834e24a9b","bugs":{"url":"https://github.com/socketio/socket.io-redis-streams-adapter/issues"},"homepage":"https://github.com/socketio/socket.io-redis-streams-adapter#readme","_nodeVersion":"20.19.1","_npmVersion":"11.3.0","dist":{"integrity":"sha512-9ttOz86edQS2RYt9ADN1l5s2kOnOG7d1wA11TRTrxOjaXa7xvTqgLjwzQL1LnVJ8C1+CipN8mDzw3PaSug3kWg==","shasum":"54ff01e8b4e46657f4441cb43ed4964405ac97a7","tarball":"https://registry.npmjs.org/@cocalc/redis-streams-adapter/-/redis-streams-adapter-0.2.3.tgz","fileCount":9,"unpackedSize":24147,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIA79KW8zx9fNSmPCBl8rzpMtIpyVzIx1HdOt1Bd/lGzWAiEA5HchKDA8jYf0jaBwS4ByYdxlqcglAjM0L+LdX6Wcy+U="}]},"_npmUser":{"name":"wstein","email":"wstein@sagemath.com","actor":{"name":"wstein","email":"wstein@sagemath.com","type":"user"}},"directories":{},"maintainers":[{"name":"wstein","email":"wstein@sagemath.com"},{"name":"hasch","email":"harald.schilly@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/redis-streams-adapter_0.2.3_1750205435169_0.9669052417772088"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-18T00:10:35.063Z","0.2.3":"2025-06-18T00:10:35.336Z","modified":"2025-06-18T00:10:35.668Z"},"maintainers":[{"name":"wstein","email":"wstein@sagemath.com"},{"name":"hasch","email":"harald.schilly@gmail.com"}],"description":"The Socket.IO adapter based on Redis Streams, allowing to broadcast events between several Socket.IO servers. (CoCalc fork.)","homepage":"https://github.com/socketio/socket.io-redis-streams-adapter#readme","keywords":["socket.io","redis","adapter"],"repository":{"type":"git","url":"git+ssh://git@github.com/socketio/socket.io-redis-streams-adapter.git"},"bugs":{"url":"https://github.com/socketio/socket.io-redis-streams-adapter/issues"},"license":"MIT","readme":"# Socket.IO Redis Streams adapter\n\nThe `@socket.io/redis-streams-adapter` package allows broadcasting packets between multiple Socket.IO servers.\n\n**Table of contents**\n\n- [Supported features](#supported-features)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [With the `redis` package](#with-the-redis-package)\n  - [With the `redis` package and a Redis cluster](#with-the-redis-package-and-a-redis-cluster)\n  - [With the `ioredis` package](#with-the-ioredis-package)\n  - [With the `ioredis` package and a Redis cluster](#with-the-ioredis-package-and-a-redis-cluster)\n- [Options](#options)\n- [How it works](#how-it-works)\n- [License](#license)\n\n## Supported features\n\n| Feature                         | `socket.io` version | Support                                        |\n|---------------------------------|---------------------|------------------------------------------------|\n| Socket management               | `4.0.0`             | :white_check_mark: YES (since version `0.1.0`) |\n| Inter-server communication      | `4.1.0`             | :white_check_mark: YES (since version `0.1.0`) |\n| Broadcast with acknowledgements | `4.5.0`             | :white_check_mark: YES (since version `0.1.0`) |\n| Connection state recovery       | `4.6.0`             | :white_check_mark: YES (since version `0.1.0`) |\n\n## Installation\n\n```\nnpm install @socket.io/redis-streams-adapter redis\n```\n\n## Usage\n\n### With the `redis` package\n\n```js\nimport { createClient } from \"redis\";\nimport { Server } from \"socket.io\";\nimport { createAdapter } from \"@socket.io/redis-streams-adapter\";\n\nconst redisClient = createClient({ url: \"redis://localhost:6379\" });\n\nawait redisClient.connect();\n\nconst io = new Server({\n  adapter: createAdapter(redisClient)\n});\n\nio.listen(3000);\n```\n\n### With the `redis` package and a Redis cluster\n\n```js\nimport { createCluster } from \"redis\";\nimport { Server } from \"socket.io\";\nimport { createAdapter } from \"@socket.io/redis-streams-adapter\";\n\nconst redisClient = createCluster({\n  rootNodes: [\n    {\n      url: \"redis://localhost:7000\",\n    },\n    {\n      url: \"redis://localhost:7001\",\n    },\n    {\n      url: \"redis://localhost:7002\",\n    },\n  ],\n});\n\nawait redisClient.connect();\n\nconst io = new Server({\n  adapter: createAdapter(redisClient)\n});\n\nio.listen(3000);\n```\n\n### With the `ioredis` package\n\n```js\nimport { Redis } from \"ioredis\";\nimport { Server } from \"socket.io\";\nimport { createAdapter } from \"@socket.io/redis-streams-adapter\";\n\nconst redisClient = new Redis();\n\nconst io = new Server({\n  adapter: createAdapter(redisClient)\n});\n\nio.listen(3000);\n```\n\n### With the `ioredis` package and a Redis cluster\n\n```js\nimport { Cluster } from \"ioredis\";\nimport { Server } from \"socket.io\";\nimport { createAdapter } from \"@socket.io/redis-streams-adapter\";\n\nconst redisClient = new Cluster([\n  {\n    host: \"localhost\",\n    port: 7000,\n  },\n  {\n    host: \"localhost\",\n    port: 7001,\n  },\n  {\n    host: \"localhost\",\n    port: 7002,\n  },\n]);\n\nconst io = new Server({\n  adapter: createAdapter(redisClient)\n});\n\nio.listen(3000);\n```\n\n## Options\n\n| Name                | Description                                                                                                       | Default value  |\n|---------------------|-------------------------------------------------------------------------------------------------------------------|----------------|\n| `streamName`        | The name of the Redis stream.                                                                                     | `socket.io`    |\n| `maxLen`            | The maximum size of the stream. Almost exact trimming (~) is used.                                                | `10_000`       |\n| `readCount`         | The number of elements to fetch per XREAD call.                                                                   | `100`          |\n| `blockTime`         | The maximum time to block per XREAD call. Set to 1 for a more realtime experience but with heavier load.          | `100`          |\n| `sessionKeyPrefix`  | The prefix of the key used to store the Socket.IO session, when the connection state recovery feature is enabled. | `sio:session:` |\n| `heartbeatInterval` | The number of ms between two heartbeats.                                                                          | `5_000`        |\n| `heartbeatTimeout`  | The number of ms without heartbeat before we consider a node down.                                                | `10_000`       |\n\n## How it works\n\nThe adapter will use a [Redis stream](https://redis.io/docs/data-types/streams/) to forward events between the Socket.IO servers.\n\nNotes:\n\n- a single stream is used for all namespaces\n- the `maxLen` option allows to limit the size of the stream\n- unlike the adapter based on Redis PUB/SUB mechanism, this adapter will properly handle any temporary disconnection to the Redis server and resume the stream\n- if [connection state recovery](https://socket.io/docs/v4/connection-state-recovery) is enabled, the sessions will be stored in Redis as a classic key/value pair\n\n## License\n\n[MIT](LICENSE)\n","readmeFilename":"README.md","_rev":"1-f4f1f8f3ceb1733fe581151101dde7a4"}