I've got a single web dyno running on a Heroku app that's built using NodeJS and it's using a single Redis To Go database on the Nano (free) tier. That tier is supposed to support up to ten connections, yet if I try to connect to it in two different modules using:
var redis_url = require('url').parse(process.env.REDISTOGO_URL);
var redis = require('redis').createClient(redis_url.port, redis_url.hostname);
I get this error when trying to start the app:
Error: Ready check failed: NOAUTH Authentication required. Mar 31 21:52:18 <> app/web.1: at RedisClient.on_info_cmd (/app/node_modules/redis/index.js:380:35)
The REDISTOGO_URL
environment variable is set correctly, and if I remove the code from one of the modules then it starts fine with no errors. I could create one client and pass it to each module, but I'd really prefer to understand what's actually causing the problem here.
Can somebody explain what's going on?
I was not able to reproduce the exact issue you describe but i was able to get around the auth issue by doing the following
var redis_url = require('url').parse(process.env.REDISTOGO_URL)
var redisClient1 = require('redis').createClient(redis_url.port, redis_url.hostname, {auth_pass: redis_url.auth.split(":")[1]});
redisClient1.on("ready", function(){
console.log("one ready")
})
var redisClient2 = require('redis').createClient(redis_url.port, redis_url.hostname, {auth_pass: redis_url.auth.split(":")[1]});
redisClient2.on("ready", function(){
console.log("two ready")
})
Does the above work for you?