aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/lib/action_cable/connection
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2016-02-23 16:41:26 +0100
committerDavid Heinemeier Hansson <david@loudthinking.com>2016-02-23 16:41:26 +0100
commitb2c2d32908beed678b087ec4ed735cc9ff87ad7a (patch)
tree33f62a5dcf5e1bc626cfeabb78c6bf49ddf9fd14 /actioncable/lib/action_cable/connection
parent3b017856f72ac6711bfbbce2d6edd9c8b49923c1 (diff)
parentc889408e0d01f7d4fb061dbc53a2426bd359496c (diff)
downloadrails-b2c2d32908beed678b087ec4ed735cc9ff87ad7a.tar.gz
rails-b2c2d32908beed678b087ec4ed735cc9ff87ad7a.tar.bz2
rails-b2c2d32908beed678b087ec4ed735cc9ff87ad7a.zip
Merge pull request #23813 from lifo/faye-websocket
Improve Action Cable reconnection reliability
Diffstat (limited to 'actioncable/lib/action_cable/connection')
-rw-r--r--actioncable/lib/action_cable/connection/base.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/actioncable/lib/action_cable/connection/base.rb b/actioncable/lib/action_cable/connection/base.rb
index 06706860c2..60f3ad3e06 100644
--- a/actioncable/lib/action_cable/connection/base.rb
+++ b/actioncable/lib/action_cable/connection/base.rb
@@ -154,7 +154,7 @@ module ActionCable
def handle_open
connect if respond_to?(:connect)
subscribe_to_internal_channel
- beat
+ confirm_connection_monitor_subscription
message_buffer.process!
server.add_connection(self)
@@ -173,6 +173,13 @@ module ActionCable
disconnect if respond_to?(:disconnect)
end
+ def confirm_connection_monitor_subscription
+ # Send confirmation message to the internal connection monitor channel.
+ # This ensures the connection monitor state is reset after a successful
+ # websocket connection.
+ transmit ActiveSupport::JSON.encode(identifier: ActionCable::INTERNAL[:identifiers][:ping], type: ActionCable::INTERNAL[:message_types][:confirmation])
+ end
+
def allow_request_origin?
return true if server.config.disable_request_forgery_protection