Page Summary
-
Each service has a default timeout and retry policy defined in its
client.rbfile. -
Default timeout and retry policies can be overridden after a service is instantiated.
-
Setting timeouts larger than two hours may result in a
DEADLINE_EXCEEDEDerror.
Each service in the Ruby client library comes with a default timeout and retry
policy specified in that service's client.rb file. For example, you can
inspect the self.configure method in the
CampaignService client configuration.
Override default timeouts
You can override these defaults on a service instance after you instantiate it
by setting the service-level config.timeout (in seconds) or by configuring
timeout and retry_policy for individual RPC methods on config.rpcs:
require 'google/ads/google_ads'
client = Google::Ads::GoogleAds::GoogleAdsClient.new
ga_service = client.service.google_ads
ga_service.configure do |config|
# Set the default timeout (in seconds) for all RPCs on this service instance.
config.timeout = 120.0
# Override the timeout or retry policy for specific RPC methods.
config.rpcs.search_stream.timeout = 300.0
config.rpcs.search.timeout = 120.0
config.rpcs.search.retry_policy = {
'initial_delay' => 5.0,
'max_delay' => 60.0
}
end
For a complete working script, see the
set_custom_client_timeouts.rb code example on
GitHub.
Timeout limits and errors
While you can increase the client timeout duration, server-side limits still
apply. Requests that take longer than two hours might fail and raise a
Google::Ads::GoogleAds::Errors::GoogleAdsError or GRPC::DeadlineExceeded
exception with a DEADLINE_EXCEEDED status.