Victor Ferreira
Victor Ferreira

Reputation: 6449

Websocket in Rails app on Heroku is not working

I added a chat functionality in my existing RoR app with the websocket-rails (https://github.com/websocket-rails/websocket-rails) gem and I'm testing it in production mode on Heroku.

It works fine in localhost, but when I sent it to Heroku it is not receiving any further messages from the Server after the connection.

The connection works:

var WEBSOCKET_URL = 'myapponheroku.herokuapp.com/websocket'
var dispatcher = new WebSocketRails(WEBSOCKET_URL);

dispatcher.on_open = function(data) {
    console.log('Connection has been established: ', data);
};

And I see the feedback message.

But the first task is to ask the server for active rooms in my chat. I noticed nothing is returning. I put some feedback messages in the server's action that should do the first tasks and none of them are reached. The feedback I implemented is a simple pair of functions that just returns a object and prints it to the console:

Javascript

dispatcher.bind('feedback',function(data){
    console.log(data);
});

Ruby

def feedback data
   send_message :feedback, {data: data}
end

It is never triggered. Any ideas? Is the a special configuration I must do on Heroku to allow it to work?

@update

Same error on my live server hosted on AWS. Connection is established, but nothing is returned from server to client.

@update2

I wrote some code so the app would write some files when connection is established and when it asks for open rooms, right at the beginning, and the files were not created. The actions are not even being called.

Upvotes: 0

Views: 232

Answers (0)

Related Questions