trying to run websockets using action_cable sidekiq and redis (heroku redis addon).on staging env that has same redis machine im able to run everything smoothly but on production upon trying to connect to websocket: wss://XXXXXX.herokuapp.com/cable i get the next error:/app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/connection/ruby.rb:22:in
initialize': no implicit conversion of String into Integer (TypeError)`
full trace from heroku logs:
2024-05-12T13:48:46.158810+00:00 app[web.2]: #<Thread:0x0000563a510f8458 /app/vendor/bundle/ruby/2.7.0/gems/actioncable-6.1.7.7/lib/action_cable/subscription_adapter/redis.rb:150 run> terminated with exception (report_on_exception is true):2024-05-12T13:48:46.158858+00:00 app[web.2]: /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/connection/ruby.rb:22:in `initialize': no implicit conversion of String into Integer (TypeError)2024-05-12T13:48:46.158888+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/connection/ruby.rb:22:in `initialize'2024-05-12T13:48:46.158889+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/connection/ruby.rb:254:in `new'2024-05-12T13:48:46.158890+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/connection/ruby.rb:254:in `connect'2024-05-12T13:48:46.158895+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/connection/ruby.rb:306:in `connect'2024-05-12T13:48:46.158896+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/client.rb:385:in `establish_connection'2024-05-12T13:48:46.158900+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/client.rb:115:in `block in connect'2024-05-12T13:48:46.158901+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/client.rb:344:in `with_reconnect'2024-05-12T13:48:46.158910+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/client.rb:114:in `connect'2024-05-12T13:48:46.158910+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/client.rb:325:in `with_socket_timeout'2024-05-12T13:48:46.158921+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/client.rb:174:in `call_loop'2024-05-12T13:48:46.158922+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/subscribe.rb:44:in `subscription'2024-05-12T13:48:46.158926+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/subscribe.rb:14:in `subscribe'2024-05-12T13:48:46.158927+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:288:in `_subscription'2024-05-12T13:48:46.158936+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/commands/pubsub.rb:20:in `block in subscribe'2024-05-12T13:48:46.158936+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:265:in `block in synchronize'2024-05-12T13:48:46.158937+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:265:in `synchronize'2024-05-12T13:48:46.158941+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:265:in `synchronize'2024-05-12T13:48:46.158942+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/commands/pubsub.rb:19:in `subscribe'2024-05-12T13:48:46.158953+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/actioncable-6.1.7.7/lib/action_cable/subscription_adapter/redis.rb:83:in `block in listen'2024-05-12T13:48:46.158954+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/client.rb:344:in `with_reconnect'2024-05-12T13:48:46.158955+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:95:in `block in with_reconnect'2024-05-12T13:48:46.158956+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:265:in `block in synchronize'2024-05-12T13:48:46.158965+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:265:in `synchronize'2024-05-12T13:48:46.158965+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:265:in `synchronize'2024-05-12T13:48:46.158969+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:94:in `with_reconnect'2024-05-12T13:48:46.158970+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:101:in `without_reconnect'2024-05-12T13:48:46.158980+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/actioncable-6.1.7.7/lib/action_cable/subscription_adapter/redis.rb:80:in `listen'2024-05-12T13:48:46.158980+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/actioncable-6.1.7.7/lib/action_cable/subscription_adapter/redis.rb:154:in `block in ensure_listener_running'2024-05-12T13:48:46.188758+00:00 app[web.2]: /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/connection/ruby.rb:22:in `initialize': no implicit conversion of String into Integer (TypeError)2024-05-12T13:48:46.188760+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/connection/ruby.rb:22:in `initialize'2024-05-12T13:48:46.188771+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/connection/ruby.rb:254:in `new'2024-05-12T13:48:46.188771+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/connection/ruby.rb:254:in `connect'2024-05-12T13:48:46.188772+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/connection/ruby.rb:306:in `connect'2024-05-12T13:48:46.188774+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/client.rb:385:in `establish_connection'2024-05-12T13:48:46.188782+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/client.rb:115:in `block in connect'2024-05-12T13:48:46.188782+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/client.rb:344:in `with_reconnect'2024-05-12T13:48:46.188783+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/client.rb:114:in `connect'2024-05-12T13:48:46.188793+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/client.rb:325:in `with_socket_timeout'2024-05-12T13:48:46.188793+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/client.rb:174:in `call_loop'2024-05-12T13:48:46.188801+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/subscribe.rb:44:in `subscription'2024-05-12T13:48:46.188801+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/subscribe.rb:14:in `subscribe'2024-05-12T13:48:46.188802+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:288:in `_subscription'2024-05-12T13:48:46.188820+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/commands/pubsub.rb:20:in `block in subscribe'2024-05-12T13:48:46.188820+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:265:in `block in synchronize'2024-05-12T13:48:46.188828+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:265:in `synchronize'2024-05-12T13:48:46.188828+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:265:in `synchronize'2024-05-12T13:48:46.188836+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/commands/pubsub.rb:19:in `subscribe'2024-05-12T13:48:46.188837+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/actioncable-6.1.7.7/lib/action_cable/subscription_adapter/redis.rb:83:in `block in listen'2024-05-12T13:48:46.188838+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis/client.rb:344:in `with_reconnect'2024-05-12T13:48:46.188847+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:95:in `block in with_reconnect'2024-05-12T13:48:46.188847+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:265:in `block in synchronize'2024-05-12T13:48:46.188855+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:265:in `synchronize'2024-05-12T13:48:46.188855+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:265:in `synchronize'2024-05-12T13:48:46.188863+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:94:in `with_reconnect'2024-05-12T13:48:46.188863+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/redis-4.8.1/lib/redis.rb:101:in `without_reconnect'2024-05-12T13:48:46.188872+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/actioncable-6.1.7.7/lib/action_cable/subscription_adapter/redis.rb:80:in `listen'2024-05-12T13:48:46.188872+00:00 app[web.2]: from /app/vendor/bundle/ruby/2.7.0/gems/actioncable-6.1.7.7/lib/action_cable/subscription_adapter/redis.rb:154:in `block in ensure_listener_running'2024-05-12T13:48:46.268851+00:00 app[web.2]: [2] - Worker 0 (PID: 29) booted in 0.0s, phase: 02024-05-12T13:48:46.000000+00:00 app[redis-asymmetrical-47170]: Error accepting a client connection: (null)
#cable.rb:development: adapter: redis url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>test: adapter: redis url: <%= ENV["REDIS_URL"] %> ssl_params: verify_mode: <%= OpenSSL::SSL::VERIFY_NONE %>staging: adapter: redis url: <%= ENV["REDIS_URL"] %> ssl_params: verify_mode: <%= OpenSSL::SSL::VERIFY_NONE %>production: adapter: redis url: <%= ENV["REDIS_URL"] %> channel_prefix: bw_backend_production ssl_params: verify_mode: OpenSSL::SSL::VERIFY_NONE # For debugging SSL issues only
#sidekiq.rb # require 'logtail'ssl_params = { verify_mode: OpenSSL::SSL::VERIFY_NONE,}Rails.logger.info "Sidekiq SSL params: #{ssl_params.inspect}"puts "Sidekiq SSL params: #{ssl_params.inspect}"Sidekiq.configure_server do |config| redis_options = { url: ENV.fetch('REDIS_URL', 'redis://localhost:6379/1'), ssl_params: ssl_params } Rails.logger.info "Sidekiq server Redis options: #{redis_options.inspect}" puts "Sidekiq server Redis options: #{redis_options.inspect}" config.redis = redis_options config.logger = Sidekiq::Logger.new($stdout) config.logger.level = Logger::INFOendSidekiq.configure_client do |config| redis_options = { url: ENV.fetch('REDIS_URL', 'redis://localhost:6379/1'), ssl_params: ssl_params } Rails.logger.info "Sidekiq client Redis options: #{redis_options.inspect}" config.redis = redis_optionsend
#redis.rbrequire 'uri'require 'redis'redis_uri = URI.parse(ENV['REDIS_URL'] || 'redis://localhost:6379/1')redis_options = { host: redis_uri.host, port: redis_uri.port.to_i, # Convert port to integer password: redis_uri.password, ssl: redis_uri.scheme == 'rediss', # Enable SSL if scheme is 'rediss' ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE # Match ssl_cert_reqs=CERT_NONE }}redis_options[:port] = redis_uri.port.to_i if redis_uri.port# Initialize Redis clientRedis.new(redis_options)
configuration added:
config.action_cable.url = 'wss://XXXX.herokuapp.com/cable'config.action_cable.allowed_request_origins = [ 'https://XXXX.herokuapp.com']config.action_cable.disable_request_forgery_protection = true`
Gemfile.lock related gems:
sidekiq (6.5.12)connection_pool (\>= 2.2.5, \< 3)rack (\~\> 2.0)redis (\>= 4.5.0, \< 5)
tried different modifications on redis.rb , nothing changed the error