Classic SDK'deki API istekleri için bağlantı ve okuma zaman aşımı sürelerini yapılandırın.
Önemli
Her API işlemi, ${API operation name}${Request} biçiminde adlandırılan benzersiz bir istek nesnesine sahiptir; örneğin DescribeInstancesRequest.
Zaman aşımı süreleri
Bağlantı Süresi: SDK'dan sunucuya TCP bağlantısı kurmak için belirlenen zaman aşımı süresi.
Okuma Süresi: Bağlantı kurulduktan sonra istek göndermek ve tam yanıt almak için belirlenen zaman aşımı süresi.
Classic SDK, zaman aşımı sürelerini şu öncelik sırasına göre uygular: istek düzeyi ayarları, istemci düzeyi ayarları ve varsayılan değerler. Varsayılan bağlantı zaman aşımı 5 saniye, varsayılan okuma zaman aşımı ise 10 saniyedir.
IClientProfile profile = DefaultProfile.GetProfile(
// The region ID.
"<your-region-id>",
// Obtain the AccessKey ID of the Resource Access Management (RAM) user from an environment variable.
Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_ID"),
// Obtain the AccessKey secret of the RAM user from an environment variable.
Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
DefaultAcsClient client = new DefaultAcsClient(profile);
// Client-level timeout settings. These settings apply to all current requests.
DefaultAcsClient client = new DefaultAcsClient();
client.SetConnectTimeoutInMilliSeconds(1024);
client.SetReadTimeoutInMilliSeconds(2048);
// Request-level timeout settings. These settings apply only to the current request. The following code uses the DescribeInstancesRequest of ECS as an example.
DescribeInstancesRequest request = new DescribeInstancesRequest();
request.SetConnectTimeoutInMilliSeconds(1024);
request.SetReadTimeoutInMilliSeconds(2048);