0

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?

Matt Lacey
  • 8,227
  • 35
  • 58

1 Answers1

2

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?

gingermusketeer
  • 618
  • 1
  • 6
  • 6
  • Wow, I'm such an idiot. In the first module I had code to do the auth `if(url.auth) { redis.auth(url.auth.split(':')[1]); }` .. which I failed to put in the other one! Still, a better error message would have helped. – Matt Lacey Apr 02 '15 at 00:44