hubotio / hubot-redis-brain

A hubot script to persist hubot's brain using redis
69 stars 55 forks source link

Url.parse is not creating the proper value for auth_pass on Redis connection #3

Closed jtomaszon closed 9 years ago

jtomaszon commented 9 years ago

Hi all, I just realize that redis-brain is not connecting to Redis password.

jtomaszon commented 9 years ago

I just need to add the 'auth_pass' on the options: I didn't make any pull request because I'm not a developer hehehe

  client = Redis.createClient(info.port, info.hostname, {'auth_pass': info.auth})
technicalpickles commented 9 years ago

That is really interesting. The most commonly used use case for this is on Heroku with one of the redis addons, and they definitely use authentication.

I'm wondering, could you let me know which environment variable you are using? I'm also wondering if you could share the string you used with the username, password, etc REDACTED. I was mostly wondering if the auth wasn't getting parsed correctly.

For reference, you can see authentication being parsed and used here: https://github.com/hubot-scripts/hubot-redis-brain/blob/master/src/redis-brain.coffee#L56-L62

100ideas commented 9 years ago

@technicalpickles this fixed it for me when using a redistogo heroku server.

client = Redis.createClient(info.port, info.hostname, {no_ready_check: true})

By the way

$ Url.parse REDISTOGO_URL
{ protocol: 'redis:',
  slashes: true,
  auth: 'redistogo: 111111111111111111',
  host: 'sub.redistogo.com:10000',
  port: '10000',
  hostname: 'sub.redistogo.com',
  hash: null,
  search: null,
  query: null,
  pathname: null,
  path: null,
  href: 'redis://redistogo:111111111111111111@sub.redistogo.com:10000' 
}

$ Url.parse(REDISTOGO_URL).auth.split(":")[1]
'111111111111111111'
tonglil commented 9 years ago

Yup, trying to get the brain to connect to a local instance of a redis-server w/ password will not work.

Throws:

INFO Slack client now connected
INFO Discovered redis from REDIS_URL environment variable
ERROR Error: Ready check failed: NOAUTH Authentication required.

Everything else default.

MrSaints commented 9 years ago

I stumbled across the exact problem when I was trying to get it to work with Redis Labs.

You'll need to set the username and password (i.e. dummyuser:password@...). It will not parse the auth portion of the URL otherwise (thus, throwing NOAUTH Authentication required).

See: https://github.com/hubot-scripts/hubot-redis-brain/blob/master/src/redis-brain.coffee#L56-L62

Hope that helps.

johngeorgewright commented 9 years ago

Thanks @MrSaints, that works for me.

technicalpickles commented 9 years ago

This should be fixed in v0.0.3 . Please give that a try, and let me know if you are still having problems :heart:

wwgc commented 9 years ago

bin/hubot add line: export REDIS_URL=redis://user:password@localhost:6379