- 8.3.0 (Mar 2024)
- 8.2.1 (May 2023)
- 8.2.0 (May 2023)
- 8.1.0 (Feb 2023)
- 8.0.1 (Jan 2023)
- 8.0.0 (Dec 2022)
- 7.2.0 (May 2022)
- 7.1.0 (Nov 2021)
- 7.0.1 (Nov 2021)
- 7.0.0 (May 2021)
- 6.1.0 (Mar 2021)
- 6.0.1 (Nov 2020)
- 6.0.0 (Nov 2020)
- 5.4.0 (Sep 2020)
- 5.3.0 (Jun 2020)
- 5.2.0 (Aug 2017)
- 5.1.0 (Jun 2017)
8.3.0 (2024-03-13)
- sharded: allow to target a specific socket ID in dynamic mode (#525) (cca38dc)
- sharded: fix count in fetchSockets() method (#523) (bd32763)
- sharded: fix SSUBSCRIBE memory leak with ioredis (#529) (2113e8d)
8.2.1 (2023-05-14)
- sharded: ensure compatibility with ioredis (42c8ab6)
- sharded: properly unsubscribe when closing (2da8d9e)
8.2.0 (2023-05-02)
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/manual/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 7.0
[email protected]
Added in e70b1bd.
The redis
package now supports Redis cluster.
Added in 77ef42c.
The subscriptionMode
option allows to configure how many Redis Pub/Sub channels are used:
- "static": 2 channels per namespace
Useful when used with dynamic namespaces.
- "dynamic": (2 + 1 per public room) channels per namespace
The default value, useful when some rooms have a low number of clients (so only a few Socket.IO servers are notified).
const io = new Server({
adapter: createShardedAdapter(pubClient, subClient, {
subscriptionMode: "static"
})
});
Added in d3388bf.
Huge thanks to @winchell for helping!
8.1.0 (2023-02-08)
The socket.io-adapter
package was added to the list of peerDependencies
, in order to fix sync issues with the version imported by the socket.io
package (see f07ff7b).
The close()
method was implemented, in order to be used with the new cleanupEmptyChildNamespaces
option.
Reference: https://github.com/socketio/socket.io/releases/tag/4.6.0
Added in fe89f7e.
8.0.1 (2023-01-11)
This release pins the socket.io-adapter
package to version ~2.4.0
instead of ^2.4.0
.
8.0.0 (2022-12-07)
Example with msgpackr:
import { unpack, pack } from "msgpackr";
io.adapter(createAdapter(pubClient, subClient, {
parser: {
encode(val) {
return pack(val);
},
decode(val) {
return unpack(val);
}
}
}));
- remove deprecated methods (fb760d9)
- the remoteJoin(), remoteLeave(), remoteDisconnect() and sockets() methods are removed in favor of the official alternatives
Related: https://github.com/socketio/socket.io/commit/b25495c069031674da08e19aed68922c7c7a0e28
- the format of Date objects is modified in a non backward-compatible way, as notepack.io now implements the MessagePack Timestamp extension type.
Reference: https://github.com/msgpack/msgpack/blob/master/spec.md#timestamp-extension-type
Previous versions of the adapter will not be able to parse the Date objects sent by newer versions.
- Reference: https://github.com/darrachequesne/notepack/releases/tag/3.0.0
- Diff: https://github.com/darrachequesne/notepack/compare/2.3.0...3.0.1
7.2.0 (2022-05-03)
- broadcast and expect multiple acks (e4c40cc)
This feature was added in [email protected]
:
io.timeout(1000).emit("some-event", (err, responses) => {
// ...
});
Thanks to this change, it will now work with multiple Socket.IO servers.
7.1.0 (2021-11-29)
- add support for redis v4 (aa681b3)
- do not emit "error" events anymore (8e5c84f)
- send response to the requesting node only (f66de11)
7.0.1 (2021-11-15)
7.0.0 (2021-05-11)
- implement the serverSideEmit functionality (3a0f29f)
- remove direct redis dependency (c68a47c)
- rename the package to
@socket.io/redis-adapter
(3cac178)
- the library will no longer create Redis clients on behalf of the user.
Before:
io.adapter(redisAdapter({ host: "localhost", port: 6379 }));
After:
const pubClient = createClient({ host: "localhost", port: 6379 });
const subClient = pubClient.duplicate();
io.adapter(redisAdapter(pubClient, subClient));
6.1.0 (2021-03-12)
- implement utility methods from Socket.IO v4 (468c3c8)
- remove one round-trip for the requester (6c8d770)
6.0.1 (2020-11-14)
6.0.0 (2020-11-12)
- add support for Socket.IO v3 (d9bcb19)
- all the requests (for inter-node communication) now return a Promise instead of accepting a callback
Before:
io.of('/').adapter.allRooms((err, rooms) => {
console.log(rooms); // an array containing all rooms (accross every node)
});
After:
const rooms = await io.of('/').adapter.allRooms();
console.log(rooms); // a Set containing all rooms (across every node)
- RedisAdapter.clients() is renamed to RedisAdapter.sockets()
See https://github.com/socketio/socket.io-adapter/commit/130f28a43c5aca924aa2c1a318422d21ba03cdac
- RedisAdapter.customHook() and RedisAdapter.customRequest() are removed
Those methods will be replaced by a more intuitive API in a future iteration.
- support for Node.js 8 is dropped
See https://github.com/nodejs/Release
5.4.0 (2020-09-02)
- update node-redis version to 3.x (5b3ed58)
5.3.0 (2020-06-04)
- add support for Redis Cluster (7a19075)
5.2.0 (2017-08-24)
- increase default requestsTimeout to 5000 ms (37e28df)
5.1.0 (2017-06-04)
- use the requestid from response when deleting requests (4f08b1a)
- add support for ArrayBuffer (b3ad4ad)