Method: ActionCable::Server::Connections#setup_heartbeat_timer

Defined in:
actioncable/lib/action_cable/server/connections.rb

#setup_heartbeat_timerObject

WebSocket connection implementations differ on when they’ll mark a connection as stale. We basically never want a connection to go stale, as you then can’t rely on being able to communicate with the connection. To solve this, a 3 second heartbeat runs on all connections. If the beat fails, we automatically disconnect.



33
34
35
36
37
# File 'actioncable/lib/action_cable/server/connections.rb', line 33

def setup_heartbeat_timer
  @heartbeat_timer ||= event_loop.timer(BEAT_INTERVAL) do
    event_loop.post { connections.each(&:beat) }
  end
end