Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no error if password not provided but is required #258

Closed
mkozjak opened this issue Feb 22, 2016 · 5 comments
Closed

no error if password not provided but is required #258

mkozjak opened this issue Feb 22, 2016 · 5 comments

Comments

@mkozjak
Copy link

mkozjak commented Feb 22, 2016

Nothing comes up if we don't provide a password while the server demands it.

'use strict'

var co = require('co')
var Redis = require('ioredis')
Redis.Promise.onPossiblyUnhandledRejection(function(error) {
  console.log('unh error:', error)
})

// this one raises authError
co(function*() {
  var r = new Redis({
    port: 6379,
    host: '127.0.0.1',
    password: 'foo',
    autoResendUnfulfilledCommands: false
  })

  r.on('ready', () => console.log('ready'))
  r.on('error', (error) => console.log('error:', error))
  r.on('authError', (error) => console.log('authError:', error))
})

// this one doesn't
co(function*() {
  var r = new Redis({
    port: 6379,
    host: '127.0.0.1',
    password: '',
    autoResendUnfulfilledCommands: false
  })

  r.on('ready', () => console.log('ready'))
  r.on('error', (error) => console.log('error:', error))
  r.on('authError', (error) => console.log('authError:', error))
})

node v 5.6.0, OS X 10.11, ioredis 1.12.2

Am I doing something wrong?

@luin
Copy link
Collaborator

luin commented Feb 22, 2016

authError event is only emitted when the password provided is wrong. If the password is empty, ioredis won't send the AUTH command to the Redis, so that there's no chance can ioredis know the password is wrong.
However, if you send any command manually, you'll get the NOAUTH error returned by Redis server.

@mkozjak
Copy link
Author

mkozjak commented Feb 22, 2016

Thanks for responding so quickly, @luin :)

This works, yes. I'll try sending some info request if available, right after connecting to check up on that.

But why aren't you emitting a new error upon this? Or an authError? Since you emit it if the password is wrong, you should emit it when there's no password (and the server requires it).

You are definitely receiving 'NOAUTH' on connect. It gets to ReplyParser.prototype._parseResult. So you could handle it, maybe.

Regards!

@luin
Copy link
Collaborator

luin commented Feb 24, 2016

@mkozjak That makes sense. I added it to the 2.x list. Thank you for pointing this out!

@luin luin mentioned this issue Feb 24, 2016
11 tasks
@mkozjak
Copy link
Author

mkozjak commented Feb 24, 2016

Thanks!

@luin
Copy link
Collaborator

luin commented Feb 26, 2016

Closing this issue in favour of #246.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants