{"id":13990861,"url":"https://github.com/socketio/socket.io-redis-adapter","last_synced_at":"2025-05-13T21:03:50.015Z","repository":{"id":14692423,"uuid":"17412319","full_name":"socketio/socket.io-redis-adapter","owner":"socketio","description":"Adapter to enable broadcasting of events to multiple separate socket.io server nodes.","archived":false,"fork":false,"pushed_at":"2024-04-09T10:47:50.000Z","size":593,"stargazers_count":2757,"open_issues_count":40,"forks_count":485,"subscribers_count":141,"default_branch":"main","last_synced_at":"2025-05-06T20:12:45.611Z","etag":null,"topics":["redis","socket-io","websocket"],"latest_commit_sha":null,"homepage":"https://socket.io/docs/v4/redis-adapter/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/socketio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-03-04T18:30:01.000Z","updated_at":"2025-05-04T10:00:31.000Z","dependencies_parsed_at":"2024-03-13T10:49:29.248Z","dependency_job_id":"24d639e6-7dd9-4855-8e42-20278a7c8824","html_url":"https://github.com/socketio/socket.io-redis-adapter","commit_stats":{"total_commits":234,"total_committers":56,"mean_commits":4.178571428571429,"dds":0.5427350427350428,"last_synced_commit":"ef5f0da0b4928fd422afc985aec0e233d34400c0"},"previous_names":["socketio/socket.io-redis","automattic/socket.io-redis"],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketio%2Fsocket.io-redis-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketio%2Fsocket.io-redis-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketio%2Fsocket.io-redis-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketio%2Fsocket.io-redis-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/socketio","download_url":"https://codeload.github.com/socketio/socket.io-redis-adapter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253951578,"owners_count":21989529,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["redis","socket-io","websocket"],"created_at":"2024-08-09T13:03:25.563Z","updated_at":"2025-05-13T21:03:49.994Z","avatar_url":"https://github.com/socketio.png","language":"TypeScript","readme":"# Socket.IO Redis adapter\n\nThe `@socket.io/redis-adapter` package allows broadcasting packets between multiple Socket.IO servers.\n\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"./assets/adapter_dark.png\"\u003e\n  \u003cimg alt=\"Diagram of Socket.IO packets forwarded through Redis\" src=\"./assets/adapter.png\"\u003e\n\u003c/picture\u003e\n\n**Table of contents**\n\n- [Supported features](#supported-features)\n- [Installation](#installation)\n- [Compatibility table](#compatibility-table)\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  - [With Redis sharded Pub/Sub](#with-redis-sharded-pubsub)\n- [Options](#options)\n  - [Default adapter](#default-adapter)\n  - [Sharded adapter](#sharded-adapter)\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 `6.1.0`) |\n| Inter-server communication      | `4.1.0`             | :white_check_mark: YES (since version `7.0.0`) |\n| Broadcast with acknowledgements | `4.5.0`             | :white_check_mark: YES (since version `7.2.0`) |\n| Connection state recovery       | `4.6.0`             | :x: NO                                         |\n\n## Installation\n\n```\nnpm install @socket.io/redis-adapter\n```\n\n## Compatibility table\n\n| Redis Adapter version | Socket.IO server version |\n|-----------------------|--------------------------|\n| 4.x                   | 1.x                      |\n| 5.x                   | 2.x                      |\n| 6.0.x                 | 3.x                      |\n| 6.1.x                 | 4.x                      |\n| 7.x and above         | 4.3.1 and above          |\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-adapter\";\n\nconst pubClient = createClient({ url: \"redis://localhost:6379\" });\nconst subClient = pubClient.duplicate();\n\nawait Promise.all([\n  pubClient.connect(),\n  subClient.connect()\n]);\n\nconst io = new Server({\n  adapter: createAdapter(pubClient, subClient)\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-adapter\";\n\nconst pubClient = 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});\nconst subClient = pubClient.duplicate();\n\nawait Promise.all([\n  pubClient.connect(),\n  subClient.connect()\n]);\n\nconst io = new Server({\n  adapter: createAdapter(pubClient, subClient)\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-adapter\";\n\nconst pubClient = new Redis();\nconst subClient = pubClient.duplicate();\n\nconst io = new Server({\n  adapter: createAdapter(pubClient, subClient)\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-adapter\";\n\nconst pubClient = 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]);\nconst subClient = pubClient.duplicate();\n\nconst io = new Server({\n  adapter: createAdapter(pubClient, subClient)\n});\n\nio.listen(3000);\n```\n\n### With Redis sharded Pub/Sub\n\nSharded Pub/Sub was introduced in Redis 7.0 in order to help scaling the usage of Pub/Sub in cluster mode.\n\nReference: https://redis.io/docs/interact/pubsub/#sharded-pubsub\n\nA dedicated adapter can be created with the `createShardedAdapter()` method:\n\n```js\nimport { Server } from \"socket.io\";\nimport { createClient } from \"redis\";\nimport { createShardedAdapter } from \"@socket.io/redis-adapter\";\n\nconst pubClient = createClient({ host: \"localhost\", port: 6379 });\nconst subClient = pubClient.duplicate();\n\nawait Promise.all([\n  pubClient.connect(),\n  subClient.connect()\n]);\n\nconst io = new Server({\n  adapter: createShardedAdapter(pubClient, subClient)\n});\n\nio.listen(3000);\n```\n\nMinimum requirements:\n\n- Redis 7.0\n- [`redis@4.6.0`](https://github.com/redis/node-redis/commit/3b1bad229674b421b2bc6424155b20d4d3e45bd1)\n\nNote: it is not currently possible to use the sharded adapter with the `ioredis` package and a Redis cluster ([reference](https://github.com/luin/ioredis/issues/1759)).\n\n## Options\n\n### Default adapter\n\n| Name                               | Description                                                                   | Default value |\n|------------------------------------|-------------------------------------------------------------------------------|---------------|\n| `key`                              | The prefix for the Redis Pub/Sub channels.                                    | `socket.io`   |\n| `requestsTimeout`                  | After this timeout the adapter will stop waiting from responses to request.   | `5_000`       |\n| `publishOnSpecificResponseChannel` | Whether to publish a response to the channel specific to the requesting node. | `false`       |\n| `parser`                           | The parser to use for encoding and decoding messages sent to Redis.           | `-`           |\n\n### Sharded adapter\n\n| Name               | Description                                                                             | Default value |\n|--------------------|-----------------------------------------------------------------------------------------|---------------|\n| `channelPrefix`    | The prefix for the Redis Pub/Sub channels.                                              | `socket.io`   |\n| `subscriptionMode` | The subscription mode impacts the number of Redis Pub/Sub channels used by the adapter. | `dynamic`     |\n\n## License\n\n[MIT](LICENSE)\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocketio%2Fsocket.io-redis-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsocketio%2Fsocket.io-redis-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocketio%2Fsocket.io-redis-adapter/lists"}