Skip to content

Commit

Permalink
feat: set default port of sentinels to 26379. (#441)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The default port of sentinels are now 26379 instead of 6379. This shouldn't break your app in most case since few setups has the sentinel server running on 6379, but if it's your case and the port isn't set explicitly, please go to update it.
  • Loading branch information
reconbot authored and luin committed Mar 21, 2017
1 parent 245e139 commit 539fe41
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ var redis = new Redis({

## Sentinel
ioredis supports Sentinel out of the box. It works transparently as all features that work when
you connect to a single node also work when you connect to a sentinel group. Make sure to run Redis >= 2.8.12 if you want to use this feature.
you connect to a single node also work when you connect to a sentinel group. Make sure to run Redis >= 2.8.12 if you want to use this feature. Sentinels have a default port of 26379.

To connect using Sentinel, use:

Expand Down
4 changes: 2 additions & 2 deletions lib/connectors/sentinel_connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ SentinelConnector.prototype.resolve = function (endpoint, callback) {
Redis = require('../redis');
}
var client = new Redis({
port: endpoint.port,
port: endpoint.port || 26379,
host: endpoint.host,
retryStrategy: null,
enableReadyCheck: false,
Expand All @@ -232,7 +232,7 @@ function noop() {}

function isSentinelEql(a, b) {
return ((a.host || '127.0.0.1') === (b.host || '127.0.0.1')) &&
((a.port || 6379) === (b.port || 6379));
((a.port || 26379) === (b.port || 26379));
}

module.exports = SentinelConnector;
16 changes: 16 additions & 0 deletions test/functional/sentinel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ describe('sentinel', function () {

});

it('should default to the default sentinel port', function (done) {
var sentinel = new MockServer(26379);
sentinel.once('connect', function () {
redis.disconnect();
sentinel.disconnect(done);
});

var redis = new Redis({
sentinels: [
{ host: '127.0.0.1' }
],
name: 'master'
});

});

it('should try to connect to all sentinel', function (done) {
var sentinel = new MockServer(27380);
sentinel.once('connect', function () {
Expand Down

0 comments on commit 539fe41

Please sign in to comment.