Skip to content

Commit 1a4c410

Browse files
calebboydBridgeAR
authored andcommitted
docs: add note about rediss usage
1 parent 5d6e471 commit 1a4c410

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,15 @@ arguments. `createClient()` returns a `RedisClient` object. Otherwise,
234234
__Tip:__ If the Redis server runs on the same machine as the client consider
235235
using unix sockets if possible to increase throughput.
236236

237+
__Note:__ Using `'rediss://...` for the protocol in a `redis_url` will enable a TLS socket connection. However, additional TLS options will need to be passed in `options`, if required.
238+
237239
#### `options` object properties
238240
| Property | Default | Description |
239241
|-----------|-----------|-------------|
240242
| host | 127.0.0.1 | IP address of the Redis server |
241243
| port | 6379 | Port of the Redis server |
242244
| path | null | The UNIX socket string of the Redis server |
243-
| url | null | The URL of the Redis server. Format: `[redis:][rediss:]//[[user][:password@]][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]` (More info avaliable at [IANA](http://www.iana.org/assignments/uri-schemes/prov/redis)). |
245+
| url | null | The URL of the Redis server. Format: `[redis[s]:]//[[user][:password@]][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]` (More info avaliable at [IANA](http://www.iana.org/assignments/uri-schemes/prov/redis)). |
244246
| parser | javascript | __Deprecated__ Use either the built-in JS parser [`javascript`]() or the native [`hiredis`]() parser. __Note__ `node_redis` < 2.6 uses hiredis as default if installed. This changed in v.2.6.0. |
245247
| string_numbers | null | Set to `true`, `node_redis` will return Redis number values as Strings instead of javascript Numbers. Useful if you need to handle big numbers (above `Number.MAX_SAFE_INTEGER === 2^53`). Hiredis is incapable of this behavior, so setting this option to `true` will result in the built-in javascript parser being used no matter the value of the `parser` option. |
246248
| return_buffers | false | If set to `true`, then all replies will be sent to callbacks as Buffers instead of Strings. |

lib/createClient.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ module.exports = function createClient (port_arg, host_arg, options) {
3131
if (parsed.auth) {
3232
options.password = parsed.auth.split(':')[1];
3333
}
34-
if (parsed.protocol && parsed.protocol !== 'redis:') {
34+
if (parsed.protocol) {
3535
if (parsed.protocol === 'rediss:') {
3636
options.tls = options.tls || {};
37-
} else {
37+
} else if (parsed.protocol !== 'redis:') {
3838
console.warn('node_redis: WARNING: You passed "' + parsed.protocol.substring(0, parsed.protocol.length - 1) + '" as protocol instead of the "redis" protocol!');
3939
}
4040
}

test/tls.spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var helper = require('./helper');
77
var path = require('path');
88
var redis = config.redis;
99
var utils = require('../lib/utils');
10+
var tls = require('tls');
1011

1112
var tls_options = {
1213
servername: 'redis.js.org',
@@ -90,12 +91,12 @@ describe('TLS connection tests', function () {
9091

9192
it('connect with host and port provided in the tls object', function (done) {
9293
if (skip) this.skip();
93-
var tls = utils.clone(tls_options);
94-
tls.port = tls_port;
95-
tls.host = 'localhost';
94+
var tls_opts = utils.clone(tls_options);
95+
tls_opts.port = tls_port;
96+
tls_opts.host = 'localhost';
9697
client = redis.createClient({
9798
connect_timeout: 1000,
98-
tls: tls
99+
tls: tls_opts
99100
});
100101

101102
// verify connection is using TCP, not UNIX socket
@@ -109,17 +110,16 @@ describe('TLS connection tests', function () {
109110
});
110111

111112
describe('using rediss as url protocol', function (done) {
112-
var tls = require('tls')
113-
var tlsConnect = tls.connect
113+
var tls_connect = tls.connect
114114
beforeEach(function () {
115115
tls.connect = function (options) {
116116
options = utils.clone(options)
117117
options.ca = tls_options.ca;
118-
return tlsConnect.call(tls, options);
118+
return tls_connect.call(tls, options);
119119
}
120120
})
121121
afterEach(function () {
122-
tls.connect = tlsConnect;
122+
tls.connect = tls_connect;
123123
})
124124
it('connect with tls when rediss is used as the protocol', function (done) {
125125
if (skip) this.skip();

0 commit comments

Comments
 (0)