Search code examples
ruby-on-railsrubyruby-on-rails-4websocketmessage-bus

MessageBus.callbackInterval does not work in production


I've been using the message_bus gem for a few months as a more simplified alternative to a websocket solution. The default MessageBus.callbackIntervalis too wide, so I want to narrow it. I've done this successfully in my development env. However, when deploying to production it seems that the second line below is ignored:

MessageBus.start();
MessageBus.callbackInterval = 1800; # this should change the interval frequency, but it doesn't
MessageBus.subscribe("/some_id", function(status) {
  // work
});

Any idea how I could debug this?


Solution

  • I haven't personally encountered this problem before, but like with many JavaScript libraries/files in Rails it is probably something in the assets pipeline.

    Are you certain that you included JavaScript required for message bus to work in your view with:

    <script src="message-bus.js" type="text/javascript"></script>
    

    and in assets

    //= require message-bus
    

    If you're using a Ruby version of this gem, you can always try to set this using Ruby instead of JavaScript.

    client = MessageBus::Client.new('http://127.0.0.1/8000') #port is optional
    #you should be able to do 
    client.callbackInterval = 1800
    #after that you should be able to do 
    
    
    client.subscribe('/message') do |payload|
      # Do stuff
    end
    

    For more info refer to https://github.com/lowjoel/message_bus-client