Skip to content

Instantly share code, notes, and snippets.

@confact
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save confact/70f3d29019c17c52c308 to your computer and use it in GitHub Desktop.
Save confact/70f3d29019c17c52c308 to your computer and use it in GitHub Desktop.
Websocket-rails sidekiq problem

I use capistrano, puma and nginx for the server. sidekiq with 40 workers.

gem 'websocket-rails', github: 'moaa/websocket-rails', branch: 'threadsocket-rails'
gem 'websocket-rails-js', github: 'websocket-rails/websocket-rails-js', branch: 'sub_protocols'
# Logfile created on 2015-01-03 15:12:50 +0100 by logger.rb/44203
I [17327] [2015-01-03 15:12:50.279] [Synchronize] Server Registered: cdHVoJkK8y2MOsBHnqvyFw
I [17327] [2015-01-03 15:13:13.863] [Synchronize] Server Removed: cdHVoJkK8y2MOsBHnqvyFw
I [17580] [2015-01-03 15:13:17.302] [Synchronize] Server Registered: rZxxeSGzshGJYT8sNQ5ysg
I [17580] [2015-01-03 15:13:17.332] [Synchronize] Server Removed: rZxxeSGzshGJYT8sNQ5ysg
I [18000] [2015-01-03 15:13:21.637] [Synchronize] Server Registered: FaOlEaMH74Q_FtgqF_053A
I [18000] [2015-01-03 15:13:22.137] [Channel] [station9788][#<Celluloid::Thread:0x00000001c41a48>] {"id"=>"54a7f9014465624650000000", "name"=>"Evanescence", "title"=>"Everybody's Fool in diretta catwoman_wj", "week"=>1, "year"=>2015, "station_id"=>9788, "info"=>nil, "date"=>"2015-01-03T14:13:21+00:00"}
I [18000] [2015-01-03 15:13:22.242] [Channel] [station9799][#<Celluloid::Thread:0x00000001659158>] {"id"=>"54a7f9014465624650020000", "name"=>"Eko Fresh", "title"=>"Die Abrechnung", "week"=>1, "year"=>2015, "station_id"=>9799, "info"=>nil, "date"=>"2015-01-03T14:13:21+00:00"}
I [18000] [2015-01-03 15:13:22.405] [Channel] [station9800][#<Celluloid::Thread:0x0000000161aea8>] {"id"=>"54a7f9014465624650010000", "name"=>"Cloud7", "title"=>"Silence (Original Remix) | ..::Antenne 3LiveRadio::.. | Moderator(in): STREAM (..::Antenne 3Live Radio::..)", "week"=>1, "year"=>2015, "station_id"=>9800, "info"=>nil, "date"=>"2015-01-03T14:13:21+00:00"}
I [18000] [2015-01-03 15:13:22.479] [Channel] [station9820][#<Celluloid::Thread:0x00000001bd0488>] {"id"=>"54a7f9024465624650030000", "name"=>"Sam Smith", "title"=>"Money On My Mind", "week"=>1, "year"=>2015, "station_id"=>9820, "info"=>{"_id"=>{"$oid"=>"54888cf9446562781f470100"}, "image"=>{"url"=>"http://cdn.devality.com/albums/54888cf9446562781f470100/95879371.png", "thumb"=>{"url"=>"http://cdn.devality.com/albums/54888cf9446562781f470100/thumb_95879371.png"}, "preview"=>{"url"=>"http://cdn.devality.com/albums/54888cf9446562781f470100/preview_95879371.png"}}, "name"=>"sam smith", "title"=>"money on my mind", "urls"=>{"spotify"=>"spotify:track:3PRLM4FzhplXfySa4B7bxS"}}, "date"=>"2015-01-03T14:13:22+00:00"}
I [18210] [2015-01-03 15:13:22.524] [Synchronize] Server Registered: VR92jgfU43WFqrKyPtOsKQ
I [18000] [2015-01-03 15:13:22.605] [Channel] [station9852][#<Celluloid::Thread:0x00000007597cf0>] {"id"=>"54a7f9024465624650040000", "name"=>"Case/Ja Rule", "title"=>"Livin' It Up (clean)", "week"=>1, "year"=>2015, "station_id"=>9852, "info"=>nil, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:22.632] [Channel] [station9806][#<Celluloid::Thread:0x00000001ca0c50>] {"id"=>"54a7f9024465624650050000", "name"=>"Duke Dumont", "title"=>"Need U (100%) ft A*M*M", "week"=>1, "year"=>2015, "station_id"=>9806, "info"=>nil, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:22.637] [Channel] [station9818][#<Celluloid::Thread:0x00000001c025f0>] {"id"=>"54a7f9024465624650070000", "name"=>"Pat C. Miller & Her Five Aces", "title"=>"Cool Cat ", "week"=>1, "year"=>2015, "station_id"=>9818, "info"=>nil, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:22.665] [Channel] [station9805][#<Celluloid::Thread:0x00000001cbcd38>] {"id"=>"54a7f9024465624650060000", "name"=>"Awe", "title"=>"Crystals (Djemba Djemba Nightcore Remix)", "week"=>1, "year"=>2015, "station_id"=>9805, "info"=>{"_id"=>{"$oid"=>"548f439d446562550f33ae00"}, "image"=>{"url"=>nil, "thumb"=>{"url"=>nil}, "preview"=>{"url"=>nil}}, "name"=>"awe", "title"=>"crystals (djemba djemba nightcore remix)", "urls"=>{"spotify"=>"spotify:track:22x1g0ATCYPGPHKO5DOgSn"}}, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:22.763] [Channel] [stations][#<Celluloid::Thread:0x00000001c41a48>] {"id"=>"54a7f9014465624650000000", "name"=>"Evanescence", "title"=>"Everybody's Fool in diretta catwoman_wj", "week"=>1, "year"=>2015, "station_id"=>9788, "info"=>nil, "date"=>"2015-01-03T14:13:21+00:00"}
I [18000] [2015-01-03 15:13:22.939] [Channel] [station9853][#<Celluloid::Thread:0x0000000759d088>] {"id"=>"54a7f9024465624650080000", "name"=>"Luna", "title"=>"Tekila, limun i so", "week"=>1, "year"=>2015, "station_id"=>9853, "info"=>nil, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:22.949] [Channel] [stations][#<Celluloid::Thread:0x0000000759d088>] {"id"=>"54a7f9024465624650080000", "name"=>"Luna", "title"=>"Tekila, limun i so", "week"=>1, "year"=>2015, "station_id"=>9853, "info"=>nil, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:23.111] [Channel] [station9854][#<Celluloid::Thread:0x000000075a26c8>] {"id"=>"54a7f9024465624650090000", "name"=>"Ev.-Luth. St. Johannesgemeinde", "title"=>"Altjahrsabend 2014 - Evangeliumslesung Lukas 12,35-40", "week"=>1, "year"=>2015, "station_id"=>9854, "info"=>nil, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:23.115] [Channel] [stations][#<Celluloid::Thread:0x000000075a26c8>] {"id"=>"54a7f9024465624650090000", "name"=>"Ev.-Luth. St. Johannesgemeinde", "title"=>"Altjahrsabend 2014 - Evangeliumslesung Lukas 12,35-40", "week"=>1, "year"=>2015, "station_id"=>9854, "info"=>nil, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:23.132] [Channel] [stations][#<Celluloid::Thread:0x00000001659158>] {"id"=>"54a7f9014465624650020000", "name"=>"Eko Fresh", "title"=>"Die Abrechnung", "week"=>1, "year"=>2015, "station_id"=>9799, "info"=>nil, "date"=>"2015-01-03T14:13:21+00:00"}
I [18000] [2015-01-03 15:13:23.206] [Channel] [station9863][#<Celluloid::Thread:0x00000001c13918>] {"id"=>"54a7f90244656246500a0000", "name"=>"1975", "title"=>"Sex (Mark Need Radio Mix)", "week"=>1, "year"=>2015, "station_id"=>9863, "info"=>nil, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:23.215] [Channel] [stations][#<Celluloid::Thread:0x00000001c13918>] {"id"=>"54a7f90244656246500a0000", "name"=>"1975", "title"=>"Sex (Mark Need Radio Mix)", "week"=>1, "year"=>2015, "station_id"=>9863, "info"=>nil, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:23.235] [Channel] [station9842][#<Celluloid::Thread:0x00000000ec5a68>] {"id"=>"54a7f90244656246500b0000", "name"=>"Ramblin' Jack Elliott", "title"=>"Ramblin' Jack Elliott / Pastures of Plenty", "week"=>1, "year"=>2015, "station_id"=>9842, "info"=>{"_id"=>{"$oid"=>"548f187d446562550fbb5400"}, "image"=>{"url"=>nil, "thumb"=>{"url"=>nil}, "preview"=>{"url"=>nil}}, "name"=>"ramblin' jack elliott", "title"=>"ramblin' jack elliott / pastures of plenty", "urls"=>{"spotify"=>"spotify:track:4PsQYEIVKP5a3KylGCGg6C"}}, "date"=>"2015-01-03T14:13:22+00:00"}
I [18210] [2015-01-03 15:13:23.305] [Channel] [station9897][#<Celluloid::Thread:0x00000006d75fb8>] {"id"=>"54a7f9034465624722000000", "name"=>"ROBBIE WILLIAMS", "title"=>"HEART AND I", "week"=>1, "year"=>2015, "station_id"=>9897, "info"=>{"_id"=>{"$oid"=>"5489ec3e446562032b280000"}, "image"=>{"url"=>"http://cdn.devality.com/albums/5489ec3e446562032b280000/52507533.png", "thumb"=>{"url"=>"http://cdn.devality.com/albums/5489ec3e446562032b280000/thumb_52507533.png"}, "preview"=>{"url"=>"http://cdn.devality.com/albums/5489ec3e446562032b280000/preview_52507533.png"}}, "name"=>"robbie williams", "title"=>"heart and i", "urls"=>{"spotify"=>"spotify:track:2AlZhxDEqikgpQ71uAUe1x"}}, "date"=>"2015-01-03T14:13:23+00:00"}
I [18210] [2015-01-03 15:13:23.306] [Channel] [stations][#<Celluloid::Thread:0x00000006d75fb8>] {"id"=>"54a7f9034465624722000000", "name"=>"ROBBIE WILLIAMS", "title"=>"HEART AND I", "week"=>1, "year"=>2015, "station_id"=>9897, "info"=>{"_id"=>{"$oid"=>"5489ec3e446562032b280000"}, "image"=>{"url"=>"http://cdn.devality.com/albums/5489ec3e446562032b280000/52507533.png", "thumb"=>{"url"=>"http://cdn.devality.com/albums/5489ec3e446562032b280000/thumb_52507533.png"}, "preview"=>{"url"=>"http://cdn.devality.com/albums/5489ec3e446562032b280000/preview_52507533.png"}}, "name"=>"robbie williams", "title"=>"heart and i", "urls"=>{"spotify"=>"spotify:track:2AlZhxDEqikgpQ71uAUe1x"}}, "date"=>"2015-01-03T14:13:23+00:00"}
I [18000] [2015-01-03 15:13:23.379] [Channel] [stations][#<Celluloid::Thread:0x00000000ec5a68>] {"id"=>"54a7f90244656246500b0000", "name"=>"Ramblin' Jack Elliott", "title"=>"Ramblin' Jack Elliott / Pastures of Plenty", "week"=>1, "year"=>2015, "station_id"=>9842, "info"=>{"_id"=>{"$oid"=>"548f187d446562550fbb5400"}, "image"=>{"url"=>nil, "thumb"=>{"url"=>nil}, "preview"=>{"url"=>nil}}, "name"=>"ramblin' jack elliott", "title"=>"ramblin' jack elliott / pastures of plenty", "urls"=>{"spotify"=>"spotify:track:4PsQYEIVKP5a3KylGCGg6C"}}, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:23.407] [Channel] [station9822][#<Celluloid::Thread:0x00000001b61920>] {"id"=>"54a7f90244656246500c0000", "name"=>"Dave Koz", "title"=>"25 Or 6 To 4", "week"=>1, "year"=>2015, "station_id"=>9822, "info"=>{"_id"=>{"$oid"=>"54958187446562550fedf50a"}, "image"=>{"url"=>"http://cdn.devality.com/albums/54958187446562550fedf50a/91175823.jpg", "thumb"=>{"url"=>"http://cdn.devality.com/albums/54958187446562550fedf50a/thumb_91175823.jpg"}, "preview"=>{"url"=>"http://cdn.devality.com/albums/54958187446562550fedf50a/preview_91175823.jpg"}}, "name"=>"dave koz", "title"=>"25 or 6 to 4", "urls"=>{"spotify"=>"spotify:track:4rmsNnkWN7EQ3fSC1LTh19"}}, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:23.409] [Channel] [stations][#<Celluloid::Thread:0x00000001b61920>] {"id"=>"54a7f90244656246500c0000", "name"=>"Dave Koz", "title"=>"25 Or 6 To 4", "week"=>1, "year"=>2015, "station_id"=>9822, "info"=>{"_id"=>{"$oid"=>"54958187446562550fedf50a"}, "image"=>{"url"=>"http://cdn.devality.com/albums/54958187446562550fedf50a/91175823.jpg", "thumb"=>{"url"=>"http://cdn.devality.com/albums/54958187446562550fedf50a/thumb_91175823.jpg"}, "preview"=>{"url"=>"http://cdn.devality.com/albums/54958187446562550fedf50a/preview_91175823.jpg"}}, "name"=>"dave koz", "title"=>"25 or 6 to 4", "urls"=>{"spotify"=>"spotify:track:4rmsNnkWN7EQ3fSC1LTh19"}}, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:23.486] [Channel] [station9839][#<Celluloid::Thread:0x00000001035768>] {"id"=>"54a7f90244656246500d0000", "name"=>"French Montana", "title"=>"Aint Worried About Nothin (Clean)", "week"=>1, "year"=>2015, "station_id"=>9839, "info"=>nil, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:23.495] [Channel] [stations][#<Celluloid::Thread:0x00000001035768>] {"id"=>"54a7f90244656246500d0000", "name"=>"French Montana", "title"=>"Aint Worried About Nothin (Clean)", "week"=>1, "year"=>2015, "station_id"=>9839, "info"=>nil, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:23.532] [Channel] [stations][#<Celluloid::Thread:0x0000000161aea8>] {"id"=>"54a7f9014465624650010000", "name"=>"Cloud7", "title"=>"Silence (Original Remix) | ..::Antenne 3LiveRadio::.. | Moderator(in): STREAM (..::Antenne 3Live Radio::..)", "week"=>1, "year"=>2015, "station_id"=>9800, "info"=>nil, "date"=>"2015-01-03T14:13:21+00:00"}
I [18210] [2015-01-03 15:13:23.690] [Channel] [station9913][#<Celluloid::Thread:0x000000047a6738>] {"id"=>"54a7f9034465624722020000", "name"=>"PITBULL", "title"=>"Back In Time", "week"=>1, "year"=>2015, "station_id"=>9913, "info"=>{"_id"=>{"$oid"=>"54887955446562256d830a00"}, "image"=>{"url"=>"http://cdn.devality.com/albums/54887955446562256d830a00/92908693.png", "thumb"=>{"url"=>"http://cdn.devality.com/albums/54887955446562256d830a00/thumb_92908693.png"}, "preview"=>{"url"=>"http://cdn.devality.com/albums/54887955446562256d830a00/preview_92908693.png"}}, "name"=>"pitbull", "title"=>"back in time", "urls"=>{"spotify"=>"spotify:track:7fmpKF0rLGPnP7kcQ5ZMm7"}}, "date"=>"2015-01-03T14:13:23+00:00"}
I [18210] [2015-01-03 15:13:23.692] [Channel] [stations][#<Celluloid::Thread:0x000000047a6738>] {"id"=>"54a7f9034465624722020000", "name"=>"PITBULL", "title"=>"Back In Time", "week"=>1, "year"=>2015, "station_id"=>9913, "info"=>{"_id"=>{"$oid"=>"54887955446562256d830a00"}, "image"=>{"url"=>"http://cdn.devality.com/albums/54887955446562256d830a00/92908693.png", "thumb"=>{"url"=>"http://cdn.devality.com/albums/54887955446562256d830a00/thumb_92908693.png"}, "preview"=>{"url"=>"http://cdn.devality.com/albums/54887955446562256d830a00/preview_92908693.png"}}, "name"=>"pitbull", "title"=>"back in time", "urls"=>{"spotify"=>"spotify:track:7fmpKF0rLGPnP7kcQ5ZMm7"}}, "date"=>"2015-01-03T14:13:23+00:00"}
I [18210] [2015-01-03 15:13:23.756] [Channel] [station9890][#<Celluloid::Thread:0x00000006d9ca00>] {"id"=>"54a7f9034465624722030000", "name"=>"Roberta Flack & Donny Hathaway", "title"=>"Back together again", "week"=>1, "year"=>2015, "station_id"=>9890, "info"=>{"_id"=>{"$oid"=>"54891b874465627665167000"}, "image"=>{"url"=>nil, "thumb"=>{"url"=>nil}, "preview"=>{"url"=>nil}}, "name"=>"roberta flack & donny hathaway", "title"=>"back together again", "urls"=>{"spotify"=>"spotify:track:3gsCAGsWr6pUm1Vy7CPPob"}}, "date"=>"2015-01-03T14:13:23+00:00"}
I [18210] [2015-01-03 15:13:23.757] [Channel] [stations][#<Celluloid::Thread:0x00000006d9ca00>] {"id"=>"54a7f9034465624722030000", "name"=>"Roberta Flack & Donny Hathaway", "title"=>"Back together again", "week"=>1, "year"=>2015, "station_id"=>9890, "info"=>{"_id"=>{"$oid"=>"54891b874465627665167000"}, "image"=>{"url"=>nil, "thumb"=>{"url"=>nil}, "preview"=>{"url"=>nil}}, "name"=>"roberta flack & donny hathaway", "title"=>"back together again", "urls"=>{"spotify"=>"spotify:track:3gsCAGsWr6pUm1Vy7CPPob"}}, "date"=>"2015-01-03T14:13:23+00:00"}
I [18000] [2015-01-03 15:13:23.761] [Channel] [stations][#<Celluloid::Thread:0x00000001bd0488>] {"id"=>"54a7f9024465624650030000", "name"=>"Sam Smith", "title"=>"Money On My Mind", "week"=>1, "year"=>2015, "station_id"=>9820, "info"=>{"_id"=>{"$oid"=>"54888cf9446562781f470100"}, "image"=>{"url"=>"http://cdn.devality.com/albums/54888cf9446562781f470100/95879371.png", "thumb"=>{"url"=>"http://cdn.devality.com/albums/54888cf9446562781f470100/thumb_95879371.png"}, "preview"=>{"url"=>"http://cdn.devality.com/albums/54888cf9446562781f470100/preview_95879371.png"}}, "name"=>"sam smith", "title"=>"money on my mind", "urls"=>{"spotify"=>"spotify:track:3PRLM4FzhplXfySa4B7bxS"}}, "date"=>"2015-01-03T14:13:22+00:00"}
I [18000] [2015-01-03 15:13:23.828] [Channel] [station9828][#<Celluloid::Thread:0x0000000143d6f8>] {"id"=>"54a7f90344656246500e0000", "name"=>"Jimmy Dore", "title"=>"Cell Phone", "week"=>1, "year"=>2015, "station_id"=>9828, "info"=>nil, "date"=>"2015-01-03T14:13:23+00:00"}
location /websocket {
proxy_pass http://puma_app_production/websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
add_header Access-Control-Allow-Origin *;
}
channel = "station" + station_id.to_s
WebsocketRails[:"#{channel}"].trigger(:new_song, stationsong.as_json)
var dispatcher = new WebSocketRails('localhost/websocket');
dispatcher.on_open = function(data) {
console.log('connected!');
var stationid = $('#songhistorylist').data("id");
var stationname = 'station' + String(stationid);
var channel = dispatcher.subscribe(stationname);
channel.bind('new_song', function (song) {
console.log(song);
console.log('a new song about ' + song.name + " - " + song.title + ' arrived!');
});
};
WebsocketRails.setup do |config|
# Uncomment to override the default log level. The log level can be
# any of the standard Logger log levels. By default it will mirror the
# current Rails environment log level.
config.log_level = :debug
# Uncomment to change the default log file path.
config.log_path = "#{Rails.root}/log/websocket_rails.log"
# Set to true if you wish to log the internal websocket_rails events
# such as the keepalive `websocket_rails.ping` event.
# config.log_internal_events = false
# Change to true to enable standalone server mode
# Start the standalone server with rake websocket_rails:start_server
# * Requires Redis
config.standalone = false
# Change to true to enable channel synchronization between
# multiple server instances.
# * Requires Redis.
config.synchronize = true
# Prevent Thin from daemonizing (default is true)
# config.daemonize = false
# Uncomment and edit to point to a different redis instance.
# Will not be used unless standalone or synchronization mode
# is enabled.
config.redis_options = {:host => 'localhost', :port => '6379'}
# By default, all subscribers in to a channel will be removed
# when that channel is made private. If you don't wish active
# subscribers to be removed from a previously public channel
# when making it private, set the following to true.
# config.keep_subscribers_when_private = false
# Set to true if you wish to broadcast channel subscriber_join and
# subscriber_part events. All subscribers of a channel will be
# notified when other clients join and part the channel. If you are
# using the UserManager, the current_user object will be sent along
# with the event.
# config.broadcast_subscriber_events = true
# Used as the key for the WebsocketRails.users Hash. This method
# will be called on the `current_user` object in your controller
# if one exists. If `current_user` does not exist or does not
# respond to the identifier, the key will default to `connection.id`
# config.user_identifier = :id
# Uncomment and change this option to override the class associated
# with your `current_user` object. This class will be used when
# synchronization is enabled and you trigger events from background
# jobs using the WebsocketRails.users UserManager.
# config.user_class = User
# Supporting HTTP streaming on Internet Explorer versions 8 & 9
# requires CORS to be enabled for GET "/websocket" request.
# List here the origin domains allowed to perform the request.
# config.allowed_origins = ['http://localhost:3000']
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment