Configure a timeout period
Updated at:
Copy as MD
Appropriate timeout settings prevent your program from blocking indefinitely on unresponsive calls and avoid premature interruptions of in-progress tasks. The V2.0 PHP SDK supports timeout configuration at the request level, client level, and through defaults.
Timeout configuration methods
Note
Timeout configurations are applied in the following order of precedence: RuntimeOption configuration, Client configuration, and default configuration.
-
Use the default configuration. Both the read timeout and the connection timeout default to 5 seconds.
-
Configure a per-request timeout by using runtime parameters (RuntimeOptions).
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions; // Set runtime parameters. These are valid only for requests that use this RuntimeOptions instance. $runtime = new RuntimeOptions([ "connectTimeout" => 5000, // Connection timeout setting "readTimeout" => 10000, // Read timeout setting ]); -
Configure a global timeout by using Config.
use Darabonba\OpenApi\Models\Config; $config = new Config([ "connectTimeout" => 5000, // Connection timeout setting "readTimeout" => 10000, // Read timeout setting ]);
Is this page helpful?