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

Using Redis in Heroku for a React and Rails API

$
0
0

I have a Rails API deployed onto heroku, which serves to a React.js Static page. There both deployed on heroku, and they comunicate through an API link. My struggle is comming when using Redis and Sidekiq.

On my Rails API I got the RedisToGo link Configured with no issues, but when I go to my React app and try to send an email invite I get this message Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED).I thought if I have it configured on my backend then it would work to my react static page app.

Sidekiq.yml

---:verbose: false:concurrency: 3staging:  :concurrency: 1production:  :concurrency: 5:queues:  - [mailers,2]  - slack_notifications  - mixpanel  - invoices  - default  - rollbar

Redis.rb

uri = URI.parse(ENV["REDISTOGO_URL"])REDIS = Redis.new(:url => uri)

sidekiq.rb

Sidekiq::Extensions.enable_delay!unless Rails.env == 'development' || Rails.env == 'test'  Sidekiq.configure_server do |config|    config.redis = {      url: Rails.application.credentials.redis_url,      password: Rails.application.credentials.redis_password    }  end  Sidekiq.configure_client do |config|    config.redis = {      url: Rails.application.credentials.redis_url,      password: Rails.application.credentials.redis_password    }  endend# Turn off backtrace if at all memory issues are popping up as# backtrace occupies to much memory on redis# number of lines of backtrace and number of re-triesSidekiq.default_worker_options = { backtrace: false, retry: 3 }Sidekiq.configure_server do |config|  # runs after your app has finished initializing  # but before any jobs are dispatched.  config.on(:startup) do    puts 'Sidekiq is starting...'    # make_some_singleton  end  config.on(:quiet) do    puts 'Got USR1, stopping further job processing...'  end  config.on(:shutdown) do    puts 'Got TERM, shutting down process...'    # stop_the_world  endend

So my question is the next one:If I have already configured a REDISTOGO_LINK on my rails app, do I need the same on my react config vars?

Whats the best way to configure sidekiq and Redis on a Rails API using react as a front-end in heroku? I haven't seen something that covers this on the internet.

I would appreciate your help! ;)


Viewing all articles
Browse latest Browse all 873

Trending Articles