Use ping option only for DCP WebSocket
* The Faye::WebSocket library will "buffer" some output of the connection and emit the `on :message` events in the order of the messages. However, when a ping is sent while the connection has already been closed, it will emit the `on :close` event immediately and drop all other messages (in that "buffer"). This is problematic for very short running executions that generate a long output (as this will be cut off without a proper exit message sent by Poseidon).
This commit is contained in:
@ -18,11 +18,7 @@ class Runner::Connection
|
||||
|
||||
def initialize(url, strategy, event_loop, locale = I18n.locale)
|
||||
Rails.logger.debug { "#{Time.zone.now.getutc.inspect}: Opening connection to #{url}" }
|
||||
# The `ping` value is measured in seconds and specifies how often a Ping frame should be sent.
|
||||
# Internally, Faye::WebSocket uses EventMachine and the `ping` value is used to wake the EventMachine thread
|
||||
# The `tls` option is used to customize the validation of TLS connections.
|
||||
# Passing `nil` as a `root_cert_file` is okay and done so for the DockerContainerPool.
|
||||
@socket = Faye::WebSocket::Client.new(url, [], strategy.class.websocket_header.merge(ping: 0.1))
|
||||
@socket = Faye::WebSocket::Client.new(url, [], strategy.class.websocket_header)
|
||||
@strategy = strategy
|
||||
@status = :established
|
||||
@event_loop = event_loop
|
||||
|
@ -129,7 +129,11 @@ class Runner::Strategy::DockerContainerPool < Runner::Strategy
|
||||
end
|
||||
|
||||
def self.websocket_header
|
||||
{}
|
||||
# The `ping` value is measured in seconds and specifies how often a Ping frame should be sent.
|
||||
# Internally, Faye::WebSocket uses EventMachine and the `ping` value is used to wake the EventMachine thread
|
||||
{
|
||||
ping: 0.1,
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -118,6 +118,8 @@ class Runner::Strategy::Poseidon < Runner::Strategy
|
||||
end
|
||||
|
||||
def self.websocket_header
|
||||
# The `tls` option is used to customize the validation of TLS connections.
|
||||
# The `headers` option is used to pass the `Poseidon-Token` as part of the initial connection request.
|
||||
{
|
||||
tls: {root_cert_file: config[:ca_file]},
|
||||
headers: {'Poseidon-Token' => config[:token]},
|
||||
|
Reference in New Issue
Block a user