Skip to content

Commit bbfb84a

Browse files
docs: add notes for the migration from socket.io-redis
Related: socketio/socket.io#4167
1 parent b068b48 commit bbfb84a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- [Cluster example](#cluster-example)
2727
- [Sentinel Example](#sentinel-example)
2828
- [Protocol](#protocol)
29+
- [Migrating from `socket.io-redis`](#migrating-from-socketio-redis)
2930
- [License](#license)
3031

3132
## How to use
@@ -312,6 +313,34 @@ A number of other libraries adopt this protocol including:
312313
- [socket.io-python-emitter](https://github.com/GameXG/socket.io-python-emitter)
313314
- [socket.io-emitter-go](https://github.com/stackcats/socket.io-emitter-go)
314315

316+
## Migrating from `socket.io-redis`
317+
318+
The package was renamed from `socket.io-redis` to `@socket.io/redis-adapter` in [v7](https://github.com/socketio/socket.io-redis-adapter/releases/tag/7.0.0), in order to match the name of the Redis emitter (`@socket.io/redis-emitter`).
319+
320+
To migrate to the new package, you'll need to make sure to provide your own Redis clients, as the package will no longer create Redis clients on behalf of the user.
321+
322+
Before:
323+
324+
```js
325+
const redisAdapter = require("socket.io-redis");
326+
327+
io.adapter(redisAdapter({ host: "localhost", port: 6379 }));
328+
```
329+
330+
After:
331+
332+
```js
333+
const { createClient } = require("redis");
334+
const { createAdapter } = require("@socket.io/redis-adapter");
335+
336+
const pubClient = createClient({ host: "localhost", port: 6379 });
337+
const subClient = pubClient.duplicate();
338+
339+
io.adapter(createAdapter(pubClient, subClient));
340+
```
341+
342+
Please note that the communication protocol between the Socket.IO servers has not been updated, so you can have some servers with `socket.io-redis` and some others with `@socket.io/redis-adapter` at the same time.
343+
315344
## License
316345

317346
MIT

0 commit comments

Comments
 (0)