I use Rails 5 in a docker environment, and I can get Action Cable to broadcast to the Sidekiq desktop perfectly using worker.new.perform.
But for the life of me, I cannot get it to broadcast when using worker.perform_async.
Here is my cable.yml:
default: &default
adapter: redis
url: <%= ENV['REDIS_PROVIDER'] %>
development:
<<: *default
test:
<<: *default
production:
<<: *default
Here is my worker:
class AdminWorker
include Sidekiq::Worker
def perform
ActionCable.server.broadcast 'admin_channel', content: 'hello'
end
end
My Admin Channel:
class AdminChannel < ApplicationCable::Channel
def subscribed
stream_from "admin_channel"
end
def unsubscribed
end
end
As I mentioned earlier, this works fine when calling AdminWorker.new.perform. As soon as I try to run AdminWorker.perform_async, the cable will not be broadcast and nothing will help with respect to the cable's action in the logs. What am I missing here?
source
share