From c889408e0d01f7d4fb061dbc53a2426bd359496c Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Fri, 19 Feb 2016 10:57:43 -0500 Subject: Fix isAlive condition and add more logging --- .../app/assets/javascripts/action_cable/connection.coffee | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'actioncable/app') 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 -- cgit v1.2.3