diff options
author | Javan Makhmali <javan@javan.us> | 2016-02-19 10:57:43 -0500 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2016-02-23 09:37:50 -0600 |
commit | c889408e0d01f7d4fb061dbc53a2426bd359496c (patch) | |
tree | 71cdb76f7dcbfd0d0b965e07668c8a527f05332b /actioncable/app | |
parent | dde833816a46c2738fa40af179751e9162a468eb (diff) | |
download | rails-c889408e0d01f7d4fb061dbc53a2426bd359496c.tar.gz rails-c889408e0d01f7d4fb061dbc53a2426bd359496c.tar.bz2 rails-c889408e0d01f7d4fb061dbc53a2426bd359496c.zip |
Fix isAlive condition and add more logging
Diffstat (limited to 'actioncable/app')
-rw-r--r-- | actioncable/app/assets/javascripts/action_cable/connection.coffee | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/actioncable/app/assets/javascripts/action_cable/connection.coffee b/actioncable/app/assets/javascripts/action_cable/connection.coffee index 39277255f7..ee888f567b 100644 --- a/actioncable/app/assets/javascripts/action_cable/connection.coffee +++ b/actioncable/app/assets/javascripts/action_cable/connection.coffee @@ -31,14 +31,16 @@ class ActionCable.Connection reopen: -> ActionCable.log("Reopening WebSocket, current state is #{@getState()}") - if @isClosed() - @open() - else + if @isAlive() try @close() + catch error + ActionCable.log("Failed to reopen WebSocket", error) finally - ActionCable.log("Failed to reopen WebSocket, retrying in #{@constructor.reopenDelay}ms") + ActionCable.log("Reopening WebSocket in #{@constructor.reopenDelay}ms") setTimeout(@open, @constructor.reopenDelay) + else + @open() isOpen: -> @isState("open") @@ -46,7 +48,7 @@ class ActionCable.Connection # Private isAlive: -> - not @isState("closing", "closed") + @webSocket? and not @isState("closing", "closed") isState: (states...) -> @getState() in states |