From 8c699fb7f2610dac4ac9a5dcda8c4f001ce043ba Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 26 Sep 2023 11:48:55 -0400 Subject: [PATCH 1/8] Update faraday timeouts --- lib/openstudio/analysis/server_api.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/openstudio/analysis/server_api.rb b/lib/openstudio/analysis/server_api.rb index 87f3976..7a0c8d9 100644 --- a/lib/openstudio/analysis/server_api.rb +++ b/lib/openstudio/analysis/server_api.rb @@ -40,6 +40,8 @@ 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.use Faraday::Response::Logger, @logger # faraday.response :logger # log requests to STDOUT faraday.adapter Faraday.default_adapter # make requests with Net::HTTP From 020fa8de11958edaab001b92581784cac3044add Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 26 Sep 2023 13:23:51 -0400 Subject: [PATCH 2/8] update faraday timeouts to basic conn --- lib/openstudio/analysis/server_api.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/openstudio/analysis/server_api.rb b/lib/openstudio/analysis/server_api.rb index 7a0c8d9..c236f8f 100644 --- a/lib/openstudio/analysis/server_api.rb +++ b/lib/openstudio/analysis/server_api.rb @@ -31,6 +31,8 @@ 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.use Faraday::Response::Logger, @logger # faraday.response @logger # log requests to STDOUT faraday.adapter Faraday.default_adapter # make requests with Net::HTTP From 0b90eb8f7a3348143a099901cc14e74aca8a78b0 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 26 Sep 2023 15:32:01 -0400 Subject: [PATCH 3/8] bump machine_status timeout --- lib/openstudio/analysis/server_api.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/openstudio/analysis/server_api.rb b/lib/openstudio/analysis/server_api.rb index c236f8f..c29e8c4 100644 --- a/lib/openstudio/analysis/server_api.rb +++ b/lib/openstudio/analysis/server_api.rb @@ -208,8 +208,8 @@ 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 if resp.status == 200 From b44a964a4fce716bf8488edeae8660bf0c7db91b Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 27 Sep 2023 09:10:53 -0400 Subject: [PATCH 4/8] add begin rescue in new_project() --- lib/openstudio/analysis/server_api.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/openstudio/analysis/server_api.rb b/lib/openstudio/analysis/server_api.rb index c29e8c4..d72ceae 100644 --- a/lib/openstudio/analysis/server_api.rb +++ b/lib/openstudio/analysis/server_api.rb @@ -101,13 +101,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 "Error: #{e.message}" end - if response.status == 201 project_id = JSON.parse(response.body)['_id'] From 69bc2fb71cf715f88b278b1dbe26c435674e8805 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 27 Sep 2023 09:18:03 -0400 Subject: [PATCH 5/8] more rescue logging --- lib/openstudio/analysis/server_api.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/openstudio/analysis/server_api.rb b/lib/openstudio/analysis/server_api.rb index d72ceae..e1d8cce 100644 --- a/lib/openstudio/analysis/server_api.rb +++ b/lib/openstudio/analysis/server_api.rb @@ -110,7 +110,7 @@ def new_project(options = {}) puts "response.status: #{response.status}" puts response.inspect rescue Net::OpenTimeout => e - puts "Error: #{e.message}" + puts "new_project OpenTimeout: #{e.message}" end if response.status == 201 project_id = JSON.parse(response.body)['_id'] @@ -215,13 +215,16 @@ def machine_status 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 From 2972626c9c1f3c070acb725425daec54cbb447bb Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 29 Sep 2023 10:19:13 -0400 Subject: [PATCH 6/8] add write_timeout to posts --- lib/openstudio/analysis/server_api.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/openstudio/analysis/server_api.rb b/lib/openstudio/analysis/server_api.rb index e1d8cce..229bfc1 100644 --- a/lib/openstudio/analysis/server_api.rb +++ b/lib/openstudio/analysis/server_api.rb @@ -33,6 +33,7 @@ def initialize(options = {}) 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 @@ -44,6 +45,7 @@ def initialize(options = {}) 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 @@ -477,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 @@ -497,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 @@ -643,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 From 65185a7229770575e95f0ebba092e78f76ee7581 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 29 Sep 2023 11:56:45 -0400 Subject: [PATCH 7/8] Update version.rb --- lib/openstudio/analysis/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From fa85db02dd55efb72ca4fa4720c302c417056667 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 29 Sep 2023 11:59:01 -0400 Subject: [PATCH 8/8] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) 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