Skip to content

Instantly share code, notes, and snippets.

@alexesDev
Created May 21, 2019 07:33
Show Gist options
  • Save alexesDev/5b0fe8006775cb27a877b5a3766465c9 to your computer and use it in GitHub Desktop.
Save alexesDev/5b0fe8006775cb27a877b5a3766465c9 to your computer and use it in GitHub Desktop.
ERR Client sent AUTH, but no password is set
class Redis
class Client
class Connector
class Sentinel
def sentinel_detect
@sentinels.each do |sentinel|
client = Client.new(@options.merge({
:host => sentinel[:host],
:port => sentinel[:port],
:password => sentinel[:password], # patch!
:reconnect_attempts => 0,
}))
begin
if result = yield(client)
# This sentinel responded. Make sure we ask it first next time.
@sentinels.delete(sentinel)
@sentinels.unshift(sentinel)
return result
end
rescue BaseConnectionError
ensure
client.disconnect
end
end
raise CannotConnectError, "No sentinels available."
rescue Redis::CommandError => err
# this feature is only available starting with Redis 5.0.1
raise if err.message !~ /ERR unknown command (`|')auth(`|')/
@options[:password] = DEFAULTS.fetch(:password)
retry
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment