ActionCable未接收数据

我使用ActionCable创建了以下内容,但无法接收任何正在广播的数据。

评论频道

class CommentsChannel < ApplicationCable::Channel def subscribed comment = Comment.find(params[:id]) stream_for comment end end 

JavaScript

 var cable = Cable.createConsumer('ws://localhost:3000/cable'); var subscription = cable.subscriptions.create({ channel: "CommentsChannel", id: 1 },{ received: function(data) { console.log("Received data") } }); 

它连接正常,我可以在日志中看到以下内容:

 CommentsChannel is streaming from comments:Z2lkOi8vdHJhZGUtc2hvdy9FdmVudC8x 

然后我广播到那个流:

 ActionCable.server.broadcast "comments:Z2lkOi8vdHJhZGUtc2hvdy9FdmVudC8x", { test: '123' } 

问题是永远不会调用received函数。 难道我做错了什么?

注意:我正在使用actioncable npm包从BackboneJS应用程序进行连接。

config/cable.yml中将电缆适配器从async更改为redis为我修复了它。 不确定为什么async不起作用。