We have been using ActionCable on Heroku for some time, and overall it works well. However, we see the H15 Idle Connection
error many times a day. They always have path=/cable
and a long service
time, so the connection was definitely lively and healthy for a while.
Dec 2016 08:32:22.057 heroku router - - at=error code=H15 desc="Idle connection" method=GET path="/cable" host=<our host> dyno=web.2 connect=1ms service=928755ms status=503
I believe that our configuration is very standard and closely follows the Rails docs for ActionCable:
module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user def connect self.current_user = find_verified_user end protected def find_verified_user if current_user = User.find_by(id: cookies.signed[:user_id]) current_user else # reject_unauthorized_connection end end end end
We have three simple channels:
class ActivitiesChannel < ApplicationCable::Channel def subscribed stream_from "activities_
Edit to add - Javascript code:
app/assets/javascripts/channels/setup.js
:
//= require cable this.App || (this.App = {}); App.cable = ActionCable.createConsumer();
app/assets/javascripts/channels/notifications.js
:
App.notifications = App.cable.subscriptions.create('NotificationsChannel', { received: function(data) { return this.showMessage(data); }, showMessage: function(data) { showNotice(data.message); } });
I am new to ActionCable and WebSockets, so I'm not sure how to fix this problem. We run Rails 5.0.0.1 with Ruby 2.3.1
Any help, context, or troubleshooting tips would be greatly appreciated!