Skip to content

Commit

Permalink
[docs] Fix Cluster example in the README
Browse files Browse the repository at this point in the history
The previous example would lead to "Connection in subscriber mode, only subscriber commands may
be used" errors.

Fixes #274
  • Loading branch information
darrachequesne committed May 4, 2018
1 parent e9cbe30 commit 8fe4e03
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ io.adapter(redisAdapter({ pubClient: pub, subClient: sub }));

```js
const io = require('socket.io')(3000);
const redisAdapter = require('socket.io-redis');
const Redis = require('ioredis');

const cluster = new Redis.Cluster([
const startupNodes = [
{
port: 6380,
host: '127.0.0.1'
Expand All @@ -207,16 +208,19 @@ const cluster = new Redis.Cluster([
port: 6381,
host: '127.0.0.1'
}
]);
];

const redisAdapter = require('socket.io-redis');
io.adapter(redisAdapter({ pubClient: cluster, subClient: cluster }));
io.adapter(redisAdapter({
pubClient: new Redis.Cluster(startupNodes),
subClient: new Redis.Cluster(startupNodes)
}));
```

### Sentinel Example

```js
const io = require('socket.io')(3000);
const redisAdapter = require('socket.io-redis');
const Redis = require('ioredis');

const options = {
Expand All @@ -227,10 +231,10 @@ const options = {
name: 'master01'
};

const pubClient = new Redis(options);
const subClient = new Redis(options);

io.adapter(redisAdapter({ pubClient: pubClient, subClient: subClient }));
io.adapter(redisAdapter({
pubClient: new Redis(options),
subClient: new Redis(options)
}));
```

## Protocol
Expand Down

0 comments on commit 8fe4e03

Please sign in to comment.