Skip to content

Commit 539fe41

Browse files
reconbotluin
authored andcommitted
feat: set default port of sentinels to 26379. (#441)
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.
1 parent 245e139 commit 539fe41

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ var redis = new Redis({
590590

591591
## Sentinel
592592
ioredis supports Sentinel out of the box. It works transparently as all features that work when
593-
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.
593+
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.
594594

595595
To connect using Sentinel, use:
596596

lib/connectors/sentinel_connector.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ SentinelConnector.prototype.resolve = function (endpoint, callback) {
210210
Redis = require('../redis');
211211
}
212212
var client = new Redis({
213-
port: endpoint.port,
213+
port: endpoint.port || 26379,
214214
host: endpoint.host,
215215
retryStrategy: null,
216216
enableReadyCheck: false,
@@ -232,7 +232,7 @@ function noop() {}
232232

233233
function isSentinelEql(a, b) {
234234
return ((a.host || '127.0.0.1') === (b.host || '127.0.0.1')) &&
235-
((a.port || 6379) === (b.port || 6379));
235+
((a.port || 26379) === (b.port || 26379));
236236
}
237237

238238
module.exports = SentinelConnector;

test/functional/sentinel.js

+16
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@ describe('sentinel', function () {
1818

1919
});
2020

21+
it('should default to the default sentinel port', function (done) {
22+
var sentinel = new MockServer(26379);
23+
sentinel.once('connect', function () {
24+
redis.disconnect();
25+
sentinel.disconnect(done);
26+
});
27+
28+
var redis = new Redis({
29+
sentinels: [
30+
{ host: '127.0.0.1' }
31+
],
32+
name: 'master'
33+
});
34+
35+
});
36+
2137
it('should try to connect to all sentinel', function (done) {
2238
var sentinel = new MockServer(27380);
2339
sentinel.once('connect', function () {

0 commit comments

Comments
 (0)