Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionCable Continuous Connect/Disconnect Loop

My rails application is using the ActionCable gem, configured as a simple chat application with one channel.

The close event keeps getting called, then reopened continuously. My Rails server is seeing the connection properly; the loop is happening in the browser/Javascript.

 Connection.prototype.events = {
      message: function(event) {
        var identifier, message, ref;
        ref = JSON.parse(event.data), identifier = ref.identifier, message = ref.message;
        return this.consumer.subscriptions.notify(identifier, "received", message);
      },
      open: function() {
        this.disconnected = false;
        return this.consumer.subscriptions.reload();
      },
      close: function() {
        return this.disconnect();
      },
      error: function() {
        return this.disconnect();
      }
    };

Has anyone experienced this issue?

like image 818
vanboom Avatar asked Sep 18 '15 05:09

vanboom


1 Answers

Make sure you are using a server other than thin. I had this issue and banged my head against my keyboard for 3 days until trying a different server (puma) and was able to solve my issue. https://github.com/puma/puma

like image 75
bp974 Avatar answered Oct 21 '22 05:10

bp974