title: Rails ActionCable didn't receiving data
body: <p>I have two servers</p>
  
  <ol>
  <li>APIs server(Rails &amp; ActionCable)</li>
  <li>Customer server(Rails 5.1 &amp; Vue js &amp; <a href="https://yarnpkg.com/zh-Hans/package/actioncable" rel="nofollow noreferrer">actioncable from Yarn</a>)</li>
  </ol>
  
  <p><strong>on APIs server</strong>:</p>
  
  <p>in app/channels/operation_channel.rb</p>
  
  <pre><code>class OperationChannel &lt; ApplicationCable::Channel
      def subscribed
          stream_from 'operations'
      end
  
      def unsubscribed
          # Any cleanup needed when channel is unsubscribed
      end
  end
  </code></pre>
  
  <p>in config/environments/production.rb</p>
  
  <pre><code>config.action_cable.disable_request_forgery_protection = true
  </code></pre>
  
  <p>in config/routes.rb</p>
  
  <pre><code>mount ActionCable.server =&gt; '/cable'
  </code></pre>
  
  <p>in app/models/operation.rb</p>
  
  <pre><code>class Operation &lt; ApplicationRecord
      [...]
  
      after_update :broadcast
  
      def broadcast
          ActionCable.server.broadcast "operations", operation: self
      end
  
      [...]
  end
  </code></pre>
  
  <p><strong>on Customer server</strong>:</p>
  
  <p>in main.js</p>
  
  <pre><code>import ActionCable from 'actioncable'
  
  var cable = ActionCable.createConsumer('wss://[APIs server URL]/cable');
  
  var operations = cable.subscriptions.create('OperationChannel', {
      connected: function() {
          console.log("connected");
      },
      disconnected: function() {
          console.log("disconnected");
      },
      received: function(data) {
          console.log('received');
          console.log(data);
      }
  });
  </code></pre>
  
  <p>I can only get disconnected callback called when the web-socket server stopping, and I can see web-socket info in the log:</p>
  
  <pre><code>Started GET "/cable/" [WebSocket] ...
  Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: upgrade, HTTP_UPGRADE: websocket)
  .
  .
  .
  [ActionCable] Broadcasting to operations: {:operation=&gt;#&lt;Operation id: 1,...
  </code></pre>
  
  <p>I have done a lot of research, but still can receive any data from broadcasting and the connected callback never be called too, please help. Thanks</p>