An endpoint is the address of the API server of an Alibaba Cloud service. Alibaba Cloud SDK has a built-in endpoint addressing module. After a request is sent, Alibaba Cloud SDK will find the endpoint to use according to the region ID and product ID that are specified when creating a client.
Automatic addressing
Each service may have different endpoints in different regions. For example, the endpoint
of an ECS instance in China (Hangzhou) is ecs.cn-hangzhou.aliyuncs.com
, but the endpoint is ecs.ap-northeast-1.aliyuncs.com
if the ECS instance is located in Japan (Tokyo).
You must specify a region ID while initializing an AcsClient object. An endpoint is
returned based on the specified region ID and service name. For example, if the region
ID of the client that is created by using the ECS SDK is set to cn-hangzhou, the endpoint is ecs.cn-hangzhou.aliyuncs.com
.
client = AcsClient(
"<your-access-key-id>",
"<your-access-key-secret>",
"<your-region-id>" # Note the sequence of the parameters. The third parameter is Region ID.
);
Configure an endpoint
$request = new DescribeInstancesRequest();
# Configure an endpoint for this request.
request.set_endpoint("ecs.cn-hangzhou.aliyuncs.com")
# Use the configured endpoint to initiate a request.
response = self.client.do_action_with_exception(request)
Handle exceptions
SDK.InvalidRegionID
or SDK.EndpointResolvingError
, refer to the following solutions to troubleshoot.
Error code | Error message | Solution |
---|---|---|
SDK.InvalidRegionID | can not find endpoint to access | The current SDK version is earlier than required. Upgrade the SDK core library aliyun-python-sdk-core to version 2.9.0 or later.
|
SDK.EndpointResolvingError | No such region <region-id>. Please check your region ID. | Make sure that the region ID that you entered is correct.
You can call DescribeRegions to query the region ID. |
SDK.EndpointResolvingError | No endpoint for product <product-id>. | Solution:
|
SDK.EndpointResolvingError | No endpoint in the region <region-id> for product <product-id>. | The endpoint of the service cannot be found in the specified region. Solution:
|