diff --git a/CHANGELOG.md b/CHANGELOG.md index 542b0dc..2d33a7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ OpenStudio(R) Analysis Gem Change Log ================================== +Version 1.3.5 +------------- +* Increase Timeouts and write_timeouts to deal with latencies for network related issues + Version 1.3.4 ------------- * Update licenses diff --git a/lib/openstudio/analysis/server_api.rb b/lib/openstudio/analysis/server_api.rb index 87f3976..229bfc1 100644 --- a/lib/openstudio/analysis/server_api.rb +++ b/lib/openstudio/analysis/server_api.rb @@ -31,6 +31,9 @@ def initialize(options = {}) # create connection with basic capabilities @conn = Faraday.new(url: @hostname) do |faraday| faraday.request :url_encoded # form-encode POST params + faraday.options.timeout = 300 + faraday.options.open_timeout = 300 + faraday.options.write_timeout = 1800 faraday.use Faraday::Response::Logger, @logger # faraday.response @logger # log requests to STDOUT faraday.adapter Faraday.default_adapter # make requests with Net::HTTP @@ -40,6 +43,9 @@ def initialize(options = {}) @conn_multipart = Faraday.new(url: @hostname) do |faraday| faraday.request :multipart faraday.request :url_encoded # form-encode POST params + faraday.options.timeout = 300 + faraday.options.open_timeout = 300 + faraday.options.write_timeout = 1800 faraday.use Faraday::Response::Logger, @logger # faraday.response :logger # log requests to STDOUT faraday.adapter Faraday.default_adapter # make requests with Net::HTTP @@ -97,13 +103,17 @@ def new_project(options = {}) # TODO: make this a display name and a machine name project_hash = { project: { name: (options[:project_name]).to_s } } - - response = @conn.post do |req| - req.url '/projects.json' - req.headers['Content-Type'] = 'application/json' - req.body = project_hash.to_json + begin + response = @conn.post do |req| + req.url '/projects.json' + req.headers['Content-Type'] = 'application/json' + req.body = project_hash.to_json + end + puts "response.status: #{response.status}" + puts response.inspect + rescue Net::OpenTimeout => e + puts "new_project OpenTimeout: #{e.message}" end - if response.status == 201 project_id = JSON.parse(response.body)['_id'] @@ -204,16 +214,19 @@ def machine_status begin resp = @conn.get do |req| req.url 'status.json' - req.options.timeout = 120 - req.options.open_timeout = 120 + req.options.timeout = 300 + req.options.open_timeout = 300 end - + puts "machine_status resp.status: #{resp.status}" + puts resp.inspect if resp.status == 200 j = JSON.parse resp.body, symbolize_names: true status = j if j end - rescue Faraday::ConnectionFailed - rescue Net::ReadTimeout + rescue Faraday::ConnectionFailed => e + puts "machine_Status ConnectionFailed: #{e.message}" + rescue Net::ReadTimeout => e + puts "machine_Status ReadTimeout: #{e.message}" end status @@ -466,7 +479,8 @@ def new_analysis(project_id, options) req.url "projects/#{project_id}/analyses.json" req.headers['Content-Type'] = 'application/json' req.body = formulation_json.to_json - req.options[:timeout] = 600 # seconds + req.options.timeout = 600 # seconds + req.options.write_timeout = 1800 end if response.status == 201 @@ -486,7 +500,8 @@ def new_analysis(project_id, options) payload = { file: Faraday::UploadIO.new(options[:upload_file], 'application/zip') } response = @conn_multipart.post "analyses/#{analysis_id}/upload.json", payload do |req| - req.options[:timeout] = 1800 # seconds + req.options.timeout = 1800 # seconds + req.options.write_timeout = 1800 end if response.status == 201 @@ -632,7 +647,8 @@ def start_analysis(analysis_id, options) req.url "analyses/#{analysis_id}/action.json" req.headers['Content-Type'] = 'application/json' req.body = options.to_json - req.options[:timeout] = 1800 # seconds + req.options.timeout = 1800 # seconds + req.options.write_timeout = 1800 end if response.status == 200 diff --git a/lib/openstudio/analysis/version.rb b/lib/openstudio/analysis/version.rb index 75c949d..3596f07 100644 --- a/lib/openstudio/analysis/version.rb +++ b/lib/openstudio/analysis/version.rb @@ -7,6 +7,6 @@ module OpenStudio module Analysis # format should be ^.*\-{1}[a-z]+[0-9]+ # for example: -rc1, -beta6, -customusecase0 - VERSION = '1.3.4'.freeze + VERSION = '1.3.5'.freeze end end