redis-rb icon indicating copy to clipboard operation
redis-rb copied to clipboard

Wrong client default options

Open donaldong opened this issue 5 years ago • 1 comments

Steps to repro

REDIS_URL=rediss://:[email protected]:1234 irb
require 'redis'
Redis::Client.new(host: '127.0.0.2')

Expected

A client with default port 6379 with no password

Actual

A client with the special port and password from the default REDIS_URL

 => #<Redis::Client:0x00007f9819106090 @options={:host=>"127.0.0.2", :url=>"rediss://:[email protected]:1234", :scheme=>"rediss", :port=>1234, :path=>nil, :timeout=>5.0, :password=>"secret", :db=>0, :driver=>Redis::Connection::Ruby, :id=>nil, :tcp_keepalive=>0, :reconnect_attempts=>1, :reconnect_delay=>0.0, :reconnect_delay_max=>0.5, :inherit_socket=>false, :sentinels=>nil, :role=>:master, :ssl=>true, :connect_timeout=>5.0, :read_timeout=>5.0, :write_timeout=>5.0, :_parsed=>true}, @reconnect=true, @logger=nil, @connection=nil, @command_map={}, @pending_reads=0, @connector=#<Redis::Client::Connector:0x00007f9819105938 @options={:host=>"127.0.0.2", :url=>"rediss://:[email protected]:1234", :scheme=>"rediss", :port=>1234, :path=>nil, :timeout=>5.0, :password=>"secret", :db=>0, :driver=>Redis::Connection::Ruby, :id=>nil, :tcp_keepalive=>0, :reconnect_attempts=>1, :reconnect_delay=>0.0, :reconnect_delay_max=>0.5, :inherit_socket=>false, :sentinels=>nil, :role=>:master, :ssl=>true, :connect_timeout=>5.0, :read_timeout=>5.0, :write_timeout=>5.0, :_parsed=>true}>>

This behavior is especially confusing when using Redis cluster, where REDIS_URLs are explicitly given but it's using the wrong default values to fill the client options.

donaldong avatar Oct 06 '20 07:10 donaldong

#679 describes the same issue - glad you're looking into a fix, but note that earlier efforts to resolve this ran into backwards-compatibility issues.

bpo avatar Oct 08 '20 14:10 bpo

This is fixed on master (upcoming 5.0). If either host, port or path is passed $REDIS_URL is ignored.

byroot avatar Aug 17 '22 18:08 byroot