diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2015-10-08 16:40:33 -0500 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2015-10-08 16:40:33 -0500 |
commit | 935d0450c038b6c51d31c29ab2ce449848cfd7dc (patch) | |
tree | df80af268f7588b8d5092ab69530c5f992abb5ef /lib/action_cable/server | |
parent | b099a7d2705428a4434813079f399dec54ec7611 (diff) | |
download | rails-935d0450c038b6c51d31c29ab2ce449848cfd7dc.tar.gz rails-935d0450c038b6c51d31c29ab2ce449848cfd7dc.tar.bz2 rails-935d0450c038b6c51d31c29ab2ce449848cfd7dc.zip |
Setup the heartbeat_timer in next tick to make sure EM reactor loop is running
Diffstat (limited to 'lib/action_cable/server')
-rw-r--r-- | lib/action_cable/server/connections.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/action_cable/server/connections.rb b/lib/action_cable/server/connections.rb index 455ff1ab29..4a5e21f5fd 100644 --- a/lib/action_cable/server/connections.rb +++ b/lib/action_cable/server/connections.rb @@ -22,8 +22,10 @@ module ActionCable # then can't rely on being able to receive and send to it. So there's a 3 second heartbeat running on all connections. If the beat fails, we automatically # disconnect. def setup_heartbeat_timer - @heartbeat_timer ||= EventMachine.add_periodic_timer(BEAT_INTERVAL) do - EM.next_tick { connections.map &:beat } + @heartbeat_timer ||= EM.next_tick do + EventMachine.add_periodic_timer(BEAT_INTERVAL) do + EM.next_tick { connections.map &:beat } + end end end |