lib/hyper-operation/transport/hyperstack.rb in hyper-operation-1.0.alpha1.4 vs lib/hyper-operation/transport/hyperstack.rb in hyper-operation-1.0.alpha1.5
- old
+ new
@@ -57,10 +57,12 @@
else
opts[:refresh_channels_every] = nil if opts[:refresh_channels_every] == :never
end
end
+ define_setting(:send_to_server_timeout, 10)
+
define_setting :opts, {}
define_setting :channel_prefix, 'synchromesh'
define_setting :client_logging, true
define_setting :connect_session, true
@@ -161,10 +163,13 @@
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
request.body = {
channel: channel, data: data, salt: salt, authorization: authorization
}.to_json
- http.request(request)
+ Timeout::timeout(Hyperstack.send_to_server_timeout) { http.request(request) }
+ rescue Timeout::Error
+ puts "\n********* FAILED TO RECEIVE RESPONSE FROM SERVER WITHIN #{Hyperstack.send_to_server_timeout} SECONDS. CHANGES WILL NOT BE SYNCED ************\n"
+ raise 'no server running'
end
def self.dispatch(data)
if !Hyperstack.on_server? && Connection.root_path
Hyperstack.send_to_server(data[:channel], [:dispatch, data])