Rails 5动作电缆Heroku-重新加载页面后电缆流停止
我希望有人有时间帮助我编写代码。一个多月以来,我一直在使用Rails 5使用Active Job in Action Cable,似乎没有人从我学习课程的地方发现我的代码中有什么错误 我正在使用的应用程序预计将显示2条flash消息 1.感谢您的评论(来自AJAX) 2.发布了一条新评论(来自Javascript频道代码) 以及更多内容(来自Javascript频道代码) 3.在新评论前加上前缀 4.刷新额定值 5.淡出闪光信息 然而,action cable仅传输第2、3、4项,以获得新的评论。页面重新加载后,操作电缆停止流式传输Rails 5动作电缆Heroku-重新加载页面后电缆流停止,heroku,actioncable,Heroku,Actioncable,我希望有人有时间帮助我编写代码。一个多月以来,我一直在使用Rails 5使用Active Job in Action Cable,似乎没有人从我学习课程的地方发现我的代码中有什么错误 我正在使用的应用程序预计将显示2条flash消息 1.感谢您的评论(来自AJAX) 2.发布了一条新评论(来自Javascript频道代码) 以及更多内容(来自Javascript频道代码) 3.在新评论前加上前缀 4.刷新额定值 5.淡出闪光信息 然而,action cable仅传输第2、3、4项,以获得新的评论
016-09-14T11:53:02.035002+00:00 heroku[router]: at=info method=GET path="/products/4" host=cfbikeberlinapp.herokuapp.com request_id=ad8f16fc-ac0a-4fc6-bbaf-5182127bd89d fwd="115.64.68.87" dyno=web.1 connect=0ms service=75ms status=200 bytes=8698
2016-09-14T11:53:02.420634+00:00 heroku[router]: at=info method=GET path="/assets/application-93d18917a3b22de4e50a8d8e5993dc92db143d1f1bc5b1914661670b138d5995.css" host=cfbikeberlinapp.herokuapp.com request_id=9012c627-feb5-4b38-8fa6-3b20cbf1ed20 fwd="115.64.68.87" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2016-09-14T11:53:02.303375+00:00 app[web.1]: I, [2016-09-14T11:53:02.303306 #3] INFO -- : Finished "/cable/" [WebSocket] for 115.64.68.87 at 2016-09-14 11:53:02 +0000
2016-09-14T11:53:02.303485+00:00 app[web.1]: I, [2016-09-14T11:53:02.303443 #3] INFO -- : ProductChannel stopped streaming from product:4
2016-09-14T11:53:02.693961+00:00 heroku[router]: at=info method=GET path="/assets/application-c4e466ef03b0da2f06fb6383f1a946665201a62d89bc96973d1a3b473db1f32b.js" host=cfbikeberlinapp.herokuapp.com request_id=bfc119a2-f74f-45e8-a6c4-eeb915d54807 fwd="115.64.68.87" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2016-09-14T11:53:03.527479+00:00 heroku[router]: at=info method=GET path="/assets/star-off.png" host=cfbikeberlinapp.herokuapp.com request_id=4285511d-6809-4558-b57a-9a0ae7fb8751 fwd="115.64.68.87" dyno=web.1 connect=0ms service=4ms status=304 bytes=258
我的远程回购可以在这里找到-
示例应用程序可在此处找到:
我的行动电缆启动代码为:
config/cable/yml
development:
adapter: async
test:
adapter: async
production:
adapter: postgresql
url: postgres://ybywuliqfewhzz:R4PgzgJ9IdaJ7_pdIlHkXaFkS2@ec2-54-235-221-102.compute-1.amazonaws.com:5432/dfuvk0kbffhdq5
服务器站点电缆代码app/assets/javascripts/channels/product.js
App.product = App.cable.subscriptions.create({channel:"ProductChannel"}, {
connected: function() {
// Called when the subscription is ready for use on the server
},
disconnected: function() {
// Called when the subscription has been terminated by the server
},
received: function(data) {
// Called when there's incoming data on the websocket for this channel
console.log("Hello");
$('#cable-flash').show();
$('.product-reviews').prepend(data.comment);
refreshRating();
$('.alert').delay(2000).fadeOut(3000);
},
listen_to_comments: function() {
return this.perform('listen', {
product_id: $("[data-product-id]").data("product-id")
});
}
});
$(document).on('turbolinks:load', function() {
App.product.listen_to_comments();
});
app/channels/product_channel.rb
class ProductChannel < ApplicationCable::Channel
def subscribed
# stream_from "product_channel"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
def listen(data)
stop_all_streams
stream_for data["product_id"]
end
end
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
该代码在开发过程中运行良好,但在heroku手机版和桌面版中失败。在动作电缆停止传输作业后,该代码只对一条评论有效
这是我在页面重新加载后从heroku收到的日志的摘录,该日志显示产品页面停止了流式处理
016-09-14T11:53:02.035002+00:00 heroku[router]: at=info method=GET path="/products/4" host=cfbikeberlinapp.herokuapp.com request_id=ad8f16fc-ac0a-4fc6-bbaf-5182127bd89d fwd="115.64.68.87" dyno=web.1 connect=0ms service=75ms status=200 bytes=8698
2016-09-14T11:53:02.420634+00:00 heroku[router]: at=info method=GET path="/assets/application-93d18917a3b22de4e50a8d8e5993dc92db143d1f1bc5b1914661670b138d5995.css" host=cfbikeberlinapp.herokuapp.com request_id=9012c627-feb5-4b38-8fa6-3b20cbf1ed20 fwd="115.64.68.87" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2016-09-14T11:53:02.303375+00:00 app[web.1]: I, [2016-09-14T11:53:02.303306 #3] INFO -- : Finished "/cable/" [WebSocket] for 115.64.68.87 at 2016-09-14 11:53:02 +0000
2016-09-14T11:53:02.303485+00:00 app[web.1]: I, [2016-09-14T11:53:02.303443 #3] INFO -- : ProductChannel stopped streaming from product:4
2016-09-14T11:53:02.693961+00:00 heroku[router]: at=info method=GET path="/assets/application-c4e466ef03b0da2f06fb6383f1a946665201a62d89bc96973d1a3b473db1f32b.js" host=cfbikeberlinapp.herokuapp.com request_id=bfc119a2-f74f-45e8-a6c4-eeb915d54807 fwd="115.64.68.87" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2016-09-14T11:53:03.527479+00:00 heroku[router]: at=info method=GET path="/assets/star-off.png" host=cfbikeberlinapp.herokuapp.com request_id=4285511d-6809-4558-b57a-9a0ae7fb8751 fwd="115.64.68.87" dyno=web.1 connect=0ms service=4ms status=304 bytes=258
你有没有想过?我也犯了类似的错误…你有没有发现?我得到了一个类似的错误。。。
016-09-14T11:53:02.035002+00:00 heroku[router]: at=info method=GET path="/products/4" host=cfbikeberlinapp.herokuapp.com request_id=ad8f16fc-ac0a-4fc6-bbaf-5182127bd89d fwd="115.64.68.87" dyno=web.1 connect=0ms service=75ms status=200 bytes=8698
2016-09-14T11:53:02.420634+00:00 heroku[router]: at=info method=GET path="/assets/application-93d18917a3b22de4e50a8d8e5993dc92db143d1f1bc5b1914661670b138d5995.css" host=cfbikeberlinapp.herokuapp.com request_id=9012c627-feb5-4b38-8fa6-3b20cbf1ed20 fwd="115.64.68.87" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2016-09-14T11:53:02.303375+00:00 app[web.1]: I, [2016-09-14T11:53:02.303306 #3] INFO -- : Finished "/cable/" [WebSocket] for 115.64.68.87 at 2016-09-14 11:53:02 +0000
2016-09-14T11:53:02.303485+00:00 app[web.1]: I, [2016-09-14T11:53:02.303443 #3] INFO -- : ProductChannel stopped streaming from product:4
2016-09-14T11:53:02.693961+00:00 heroku[router]: at=info method=GET path="/assets/application-c4e466ef03b0da2f06fb6383f1a946665201a62d89bc96973d1a3b473db1f32b.js" host=cfbikeberlinapp.herokuapp.com request_id=bfc119a2-f74f-45e8-a6c4-eeb915d54807 fwd="115.64.68.87" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2016-09-14T11:53:03.527479+00:00 heroku[router]: at=info method=GET path="/assets/star-off.png" host=cfbikeberlinapp.herokuapp.com request_id=4285511d-6809-4558-b57a-9a0ae7fb8751 fwd="115.64.68.87" dyno=web.1 connect=0ms service=4ms status=304 bytes=258