Skip to content

Node.js based forum software built for the modern web

closes #5069

barisusakli4eb8015017e4
diff --git a/package.json b/package.json
index e5b9112f4c..fb8b6be978 100644
--- a/package.json
+++ b/package.json
@@ -81,7 +81,7 @@
"sitemap": "^1.4.0",
"socket.io": "^1.4.8",
"socket.io-client": "^1.4.0",
- "socket.io-redis": "^1.0.0",
+ "socket.io-redis": "1.1.1",
"socketio-wildcard": "~0.3.0",
"string": "^3.0.0",
"templates.js": "0.3.4",
diff --git a/src/database/redis.js b/src/database/redis.js
index 8af568b5d9..214c9ef4a1 100644
--- a/src/database/redis.js
+++ b/src/database/redis.js
@@ -65,15 +65,18 @@
};
module.connect = function(options) {
- var redis_socket_or_host = nconf.get('redis:host'),
- cxn, dbIdx;
-
- options = options || {};
+ var redis_socket_or_host = nconf.get('redis:host');
+ var cxn;
if (!redis) {
redis = require('redis');
}
+ options = options || {};
+ if (nconf.get('redis:password')) {
+ options.auth_pass = nconf.get('redis:password');
+ }
+
if (redis_socket_or_host && redis_socket_or_host.indexOf('/') >= 0) {
/* If redis.host contains a path name character, use the unix dom sock connection. ie, /tmp/redis.sock */
cxn = redis.createClient(nconf.get('redis:host'), options);
@@ -91,7 +94,7 @@
cxn.auth(nconf.get('redis:password'));
}
- dbIdx = parseInt(nconf.get('redis:database'), 10);
+ var dbIdx = parseInt(nconf.get('redis:database'), 10);
if (dbIdx) {
cxn.select(dbIdx, function(error) {
if(error) {
diff --git a/src/socket.io/index.js b/src/socket.io/index.js
index 5ee6050571..d3393ea2d2 100644
--- a/src/socket.io/index.js
+++ b/src/socket.io/index.js
@@ -177,9 +177,8 @@ var ratelimit = require('../middleware/ratelimit');
if (nconf.get('redis')) {
var redisAdapter = require('socket.io-redis');
var redis = require('../database/redis');
- var pub = redis.connect({return_buffers: true});
+ var pub = redis.connect();
var sub = redis.connect({return_buffers: true});
-
io.adapter(redisAdapter({pubClient: pub, subClient: sub}));
} else if (nconf.get('isCluster') === 'true') {
winston.warn('[socket.io] Clustering detected, you are advised to configure Redis as a websocket store.');