I'm using Websocket-rails, sidekiq, redis, backbone.
#config/initializers/websocket_rails.rb
WebsocketRails.setup do |config|
config.standalone = false
config.synchronize = true # <= problem
uri = URI.parse(ENV["REDISTOGO_URL"] || "redis://127.0.0.1")
config.redis_options = {:host => uri.host, :port => uri.port || 6379}
end
When i use this initializer on localhost, it works well. When i push it to heroku:
$ heroku ps
=== web (1X): `bundle exec rails server -p $PORT`
web.1: crashed 2014/12/04 20:40:35 (~ 28m ago)
If i make config.synchronize = false
, it doesnt crash on heroku and on localhost, but websockets doesn't function anymore.
Additional info:
#config/initializers/redis.rb
uri = URI.parse(ENV["REDISTOGO_URL"] || "redis://127.0.0.1")
$redis = Redis.new(:host => uri.host, :port => uri.port || 6379, :password => uri.password, :driver => :hiredis)
#config/initializers/sidekiq.rb
Sidekiq.configure_server do |config|
config.redis = {driver: :hiredis}
end
#config/events.rb -> clear (this file not exist)
#app/assets/javascripts/application.js
...
//= require websocket_rails/main
//= require_tree .
var dispatcher = new WebSocketRails(window.document.location.host + '/websocket');
var channel = dispatcher.subscribe('channel_name');
Tryed everything i found on stackOverflow, google. Didnt trye yet making it standalone. Any suggestions? I need just somehow make this websockets work on heroku, and with many testings, error is only when synchronize is set to true.
Cool, i kept searching, found new example http://tgib23.github.io/blog/2014/10/30/deploy-rails-websocket-app-into-heroku/ and changed my websocket to:
WebsocketRails.setup do |config|
config.standalone = false
config.synchronize = true # <= problem
uri = URI.parse(ENV["REDISTOGO_URL"] || "redis://127.0.0.1")
config.redis_options = {:host => uri.host, :port => uri.port || 6379, :user => 'redistogo', :password => 'xxxxxxxxxxxxxxxxxxxx'}
}
end
I logged in to heroku, checked redistogo ads, took encoded password, copied it to this password here, as in example and im surprised - it works! :)