Skip to content
Snippets Groups Projects
Verified Commit c9af6cd6 authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

Add a setting for the HTTP open timeout value

parent 74ac4f59
No related branches found
No related tags found
No related merge requests found
## 1.4.1 - **Unreleased**
- Adds error event to the client abstraction, for handling errors in the background listener
- Adds an `open_timeout` setter to the API
- Fixes an overly aggressive filter for event handlers
## 1.4.0 - 2019-09-30
......
......@@ -23,7 +23,7 @@ module MatrixSdk
}.freeze
attr_accessor :access_token, :connection_address, :connection_port, :device_id, :autoretry, :global_headers
attr_reader :homeserver, :validate_certificate, :read_timeout, :protocols, :well_known, :proxy_uri
attr_reader :homeserver, :validate_certificate, :open_timeout, :read_timeout, :protocols, :well_known, :proxy_uri
ignore_inspect :access_token, :logger
......@@ -38,6 +38,7 @@ module MatrixSdk
# @option params [Boolean] :validate_certificate (false) Should the connection require valid SSL certificates
# @option params [Integer] :transaction_id (0) The starting ID for transactions
# @option params [Numeric] :backoff_time (5000) The request backoff time in milliseconds
# @option params [Numeric] :open_timeout (nil) The timeout in seconds to wait for a TCP session to open
# @option params [Numeric] :read_timeout (240) The timeout in seconds for reading responses
# @option params [Hash] :global_headers Additional headers to set for all requests
# @option params [Boolean] :skip_login Should the API skip logging in if the HS URL contains user information
......@@ -63,6 +64,7 @@ module MatrixSdk
@validate_certificate = params.fetch(:validate_certificate, false)
@transaction_id = params.fetch(:transaction_id, 0)
@backoff_time = params.fetch(:backoff_time, 5000)
@open_timeout = params.fetch(:open_timeout, nil)
@read_timeout = params.fetch(:read_timeout, 240)
@well_known = params.fetch(:well_known, {})
@global_headers = DEFAULT_HEADERS.dup
......@@ -155,6 +157,13 @@ module MatrixSdk
protocols.include? protocol
end
# @param seconds [Numeric]
# @return [Numeric]
def open_timeout=(seconds)
@http.finish if @http && @open_timeout != seconds
@open_timeout = seconds
end
# @param seconds [Numeric]
# @return [Numeric]
def read_timeout=(seconds)
......@@ -291,6 +300,7 @@ module MatrixSdk
Net::HTTP.new(host, port)
end
@http.open_timeout = open_timeout
@http.read_timeout = read_timeout
@http.use_ssl = homeserver.scheme == 'https'
@http.verify_mode = validate_certificate ? ::OpenSSL::SSL::VERIFY_NONE : nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment