Quantcast
Channel: Active questions tagged redis+ruby-on-rails - Stack Overflow
Viewing all articles
Browse latest Browse all 873

'failed: Error during WebSocket handshake: Unexpected response code: 503' shows up. Can't connect to redis on heroku

$
0
0

I'm trying to deploy chatapp on heroku but once I deploy it, ActionCable doesn't work though it works on localhost. I think because redis doesn't connect well on heroku. Could anyone please help?

Error

enter image description here

enter image description here

enter image description here

Gemfile

gem 'rails', '~> 5.2.4', '>= 5.2.4.1'# Use sqlite3 as the database for Active Record# Use Puma as the app servergem 'puma', '~> 3.11'# Use SCSS for stylesheetsgem 'sass-rails', '~> 5.0'# Use Uglifier as compressor for JavaScript assetsgem 'uglifier', '>= 1.3.0'# See https://github.com/rails/execjs#readme for more supported runtimes# gem 'mini_racer', platforms: :ruby# Use CoffeeScript for .coffee assets and viewsgem 'coffee-rails', '~> 4.2'# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinksgem 'turbolinks', '~> 5'# Build JSON APIs with ease. Read more: https://github.com/rails/jbuildergem 'jbuilder', '~> 2.5'gem 'semantic-ui-sass'gem 'jquery-rails'# Use Redis adapter to run Action Cable in production# Use ActiveModel has_secure_passwordgem 'bcrypt', '~> 3.1.7'gem 'hirb'# Use ActiveStorage variant# gem 'mini_magick', '~> 4.8'# Use Capistrano for deployment# gem 'capistrano-rails', group: :development# Reduces boot times through caching; required in config/boot.rbgem 'bootsnap', '>= 1.1.0', require: falsegroup :development, :test do  # Call 'byebug' anywhere in the code to stop execution and get a debugger console  gem 'sqlite3'  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]endgroup :development do  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.  gem 'web-console', '>= 3.3.0'  gem 'listen', '>= 3.0.5', '< 3.2'  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring  gem 'spring'  gem 'spring-watcher-listen', '~> 2.0.0'endgroup :test do  # Adds support for Capybara system testing and selenium driver  gem 'capybara', '>= 2.15'  gem 'selenium-webdriver'  # Easy installation and use of chromedriver to run system tests with Chrome  gem 'chromedriver-helper'endgroup :production do  gem 'pg', '0.20.0'  gem 'redis'  gem 'redis-rails'end# Windows does not include zoneinfo files, so bundle the tzinfo-data gemgem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

config/cable.yml

development:  adapter: asynctest:  adapter: async# production:#   adapter: redis#   url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>#   channel_prefix: twinz_pfw_2020_productionproduction:  adapter: redis  url: <%= ENV["REDIS_URL"] %>

config/application.rb

require_relative 'boot'require 'rails/all'# Require the gems listed in Gemfile, including any gems# you've limited to :test, :development, or :production.Bundler.require(*Rails.groups)module TwinzPfw2020  class Application < Rails::Application    # Initialize configuration defaults for originally generated Rails version.    config.action_cable.mount_path = '/cable'    # Settings in config/environments/* take precedence over those specified here.    # Application configuration can go into files in config/initializers    # -- all .rb files in that directory are automatically loaded after loading    # the framework and any gems in your application.  endend

config/environments/production.rb

Rails.application.configure do  # Settings specified here will take precedence over those in config/application.rb.  # Code is not reloaded between requests.  config.cache_classes = true  # Eager load code on boot. This eager loads most of Rails and  # your application in memory, allowing both threaded web servers  # and those relying on copy on write to perform better.  # Rake tasks automatically ignore this option for performance.  config.eager_load = true  # Full error reports are disabled and caching is turned on.  config.consider_all_requests_local       = false  config.action_controller.perform_caching = true  # Disable serving static files from the `/public` folder by default since  # Apache or NGINX already handles this.  config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?  # Compress JavaScripts and CSS.  config.assets.js_compressor = :uglifier  # config.assets.css_compressor = :sass  # Do not fallback to assets pipeline if a precompiled asset is missed.  config.assets.compile = false  # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb  # Enable serving of images, stylesheets, and JavaScripts from an asset server.  # config.action_controller.asset_host = 'http://assets.example.com'  # Specifies the header that your server uses for sending files.  # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX  # Mount Action Cable outside main process or domain  # config.action_cable.mount_path = nil  # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.  # config.force_ssl = true  # Use the lowest log level to ensure availability of diagnostic information  # when problems arise.  config.log_level = :debug  # Prepend all log lines with the following tags.  config.log_tags = [ :request_id ]  # Use a different cache store in production.  # config.cache_store = :mem_cache_store  # Use a real queuing backend for Active Job (and separate queues per environment)  # config.active_job.queue_adapter     = :resque  # config.active_job.queue_name_prefix = "myrecipes_#{Rails.env}"  config.action_mailer.perform_caching = false  # Ignore bad email addresses and do not raise email delivery errors.  # Set this to true and configure the email server for immediate delivery to raise delivery errors.  # config.action_mailer.raise_delivery_errors = false  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to  # the I18n.default_locale when a translation cannot be found).  config.i18n.fallbacks = true  # Send deprecation notices to registered listeners.  config.active_support.deprecation = :notify  # Use default logging formatter so that PID and timestamp are not suppressed.  config.log_formatter = ::Logger::Formatter.new  # Use a different logger for distributed setups.  # require 'syslog/logger'  # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')  if ENV["RAILS_LOG_TO_STDOUT"].present?    logger           = ActiveSupport::Logger.new(STDOUT)    logger.formatter = config.log_formatter    config.logger = ActiveSupport::TaggedLogging.new(logger)  end  # Do not dump schema after migrations.  config.active_record.dump_schema_after_migration = false  config.action_cable.url = 'wss://prayforourworld.herokuapp.com/cable'  config.web_socket_server_url = "wss://prayforourworld.herokuapp.com/cable"  config.action_cable.allowed_request_origins = [ /https?:\/\/.*/ ]  config.action_cable.allowed_request_origins = ['https://prayforourworld.herokuapp.com/', '/http:\/\/prayforourworld.herokuapp.*/']end

config/initializers/redis.rb

$redis = Redis.new(url: ENV["REDIS_URL"]) if Rails.env.production?

Viewing all articles
Browse latest Browse all 873

Trending Articles