A listener checks connection requests and distributes the requests to endpoints based on forwarding rules that are defined by the scheduling algorithm. You can call the CreateListener operation to create a listener for a GA instance.
Operation description
When you call this operation, take note of the following items:
-
CreateListener is an asynchronous operation. After a request is sent, the system returns a request ID and runs the task in the background. You can call the DescribeListener operation to query the status of the task.
- If the listener is in the init state, the listener is being created. In this state, you can perform only query operations.
- If the listener is in the active state, the listener is created.
-
You cannot repeatedly call the CreateListener operation for the same GA instance within the specified period of time.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- For mandatory resource types, indicate with a prefix of * .
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
ga:CreateListener | create | *Listener acs:ga:{#regionId}:{#accountId}:listener/* *Accelerator acs:ga:{#regionId}:{#accountId}:ga/{#acceleratorId} |
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
RegionId | string | Yes | The ID of the region where the GA instance is deployed. Set the value to cn-hangzhou. | cn-hangzhou |
ClientToken | string | No | The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters.
If you do not set this parameter, ClientToken is set to the value of RequestId. The value of RequestId is different for each API request.
| 123e4567-e89b-12d3-a456-426655440000 |
AcceleratorId | string | Yes | The ID of the GA instance. | ga-bp1odcab8tmno0hdq**** |
Name | string | No | The name of the listener. The name must be 1 to 128 characters in length and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter. | Listener |
Description | string | No | The description of the listener. The description can be up to 200 characters in length and cannot start with | Listener |
ClientAffinity | string | No | Specifies whether to enable client affinity for the listener.
| SOURCE_IP |
Protocol | string | No | The network transmission protocol that you want to use for the listener. Valid values:
| tcp |
PortRanges | array<object> | Yes | The listener ports. Valid values: 1 to 65499. The maximum number of ports that can be configured depends on the routing type and protocol of the listener. For more information, see Listener overview. | |
object | Yes | The listener ports. Valid values: 1 to 65499. The maximum number of ports that can be configured varies based on the routing type and protocol of the listener. For more information, see Listener overview. | ||
FromPort | integer | Yes | The first port of the listener port range that you want to use to receive and forward requests to endpoints. Valid values: 1 to 65499. The value of FromPort must be smaller than or equal to the value of ToPort. The maximum number of ports that can be configured varies based on the routing type and protocol of the listener. For more information, see Listener overview.
You can configure only one listener port for an HTTP or HTTPS listener. In this case, the first port is the same as the last port.
| 20 |
ToPort | integer | Yes | The last port of the listener port range that you want to use to receive and forward requests to endpoints. Valid values: 1 to 65499. The value of FromPort must be smaller than or equal to the value of ToPort. The maximum number of ports that can be configured varies based on the routing type and protocol of the listener. For more information, see Listener overview.
You can configure only one listener port for an HTTP or HTTPS listener. In this case, the first port is the same as the last port.
| 20 |
Certificates | array<object> | No | The SSL certificates. | |
object | No | The SSL certificates. | ||
Id | string | No | The ID of the SSL certificate.
This parameter is required only when you create an HTTPS listener.
| 449****-cn-hangzhou |
XForwardedForConfig | object | No | The | |
XForwardedForGaIdEnabled | boolean | No | Specifies whether to use the
This parameter is available only when you create an HTTPS or HTTP listener.
| false |
XForwardedForGaApEnabled | boolean | No | Specifies whether to use the
This parameter is available only when you create an HTTPS or HTTP listener.
| false |
XForwardedForProtoEnabled | boolean | No | Specifies whether to use the
This parameter is available only when you create an HTTPS or HTTP listener.
| false |
XForwardedForPortEnabled | boolean | No | Specifies whether to use the
This parameter is available only when you create an HTTPS or HTTP listener.
| false |
XRealIpEnabled | boolean | No | Specifies whether to use the
This parameter is available only when you create an HTTPS or HTTP listener.
| false |
SecurityPolicyId | string | No | The ID of the security policy. Valid values:
This parameter is available only when you create an HTTPS listener.
| tls_cipher_policy_1_0 |
Type | string | No | The routing type of the listener. Valid values:
| Standard |
EndpointGroupConfigurations | array<object> | No | The endpoint groups that are associated with the intelligent routing listener. You can configure up to 10 endpoint groups for an intelligent routing listener.
You can configure endpoint groups and endpoints only if you set Type to Standard.
| |
object | No | The endpoint group that is associated with the intelligent routing listener. You can configure up to 10 endpoint groups for an intelligent routing listener.
You can configure endpoint groups and endpoints only if you set Type to Standard.
| ||
EndpointGroupName | string | No | The name of the endpoint group that is associated with the intelligent routing listener. The name must be 1 to 128 characters in length and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter. You can enter the names of up to 10 endpoint groups.
You can configure endpoint groups and endpoints only if you set Type to Standard.
| test |
EndpointGroupDescription | string | No | The description of the endpoint group that is associated with the intelligent routing listener. The description can be up to 200 characters in length and cannot contain You can enter the descriptions of up to 10 endpoint groups.
You can configure endpoint groups and endpoints only if you set Type to Standard.
| test |
EndpointGroupRegion | string | No | The region ID of the endpoint group that is associated with the intelligent routing listener. You can enter the IDs of up to 10 regions.
You can configure endpoint groups and endpoints only if you set Type to Standard.
| cn-hangzhou |
TrafficPercentage | long | No | The traffic distribution ratio. If an intelligent routing listener is associated with multiple endpoint groups, you can configure this parameter to specify the ratio of traffic distributed to each endpoint group. Valid values: 1 to 100. Default value: 100. You can specify traffic distribution ratios for up to 10 endpoint groups.
You can configure endpoint groups and endpoints only if you set Type to Standard.
| 100 |
HealthCheckEnabled | boolean | No | Specifies whether to enable health checks for the endpoint group. Valid values:
You can enable the health check feature for up to 10 endpoint groups.
You can configure endpoint groups and endpoints only if you set Type to Standard.
| false |
HealthCheckIntervalSeconds | long | No | The interval at which health checks are performed. Unit: seconds. You can specify up to 10 health check intervals.
You can configure endpoint groups and endpoints only if you set Type to Standard.
| 3 |
HealthCheckPath | string | No | The health check path. You can specify up to 10 health check paths.
You can configure endpoint groups and endpoints only if you set Type to Standard.
| /healthcheck |
HealthCheckPort | long | No | The port that you want to use for health checks. Valid values: 1 to 65535. You can specify up to 10 ports for health checks.
You can configure endpoint groups and endpoints only if you set Type to Standard.
| 20 |
HealthCheckProtocol | string | No | The protocol over which health check requests are sent. Valid values:
You can specify up to 10 health check protocols.
You can configure endpoint groups and endpoints only if you set Type to Standard.
| tcp |
ThresholdCount | long | No | The number of failed consecutive health checks that must occur before a healthy endpoint group is considered unhealthy or the number of successful consecutive health checks that must occur before an unhealthy endpoint group is considered healthy. Valid values: 2 to 10. Default value: 3. You can specify up to 10 values (the number of consecutive health check successes or consecutive health check failures).
You can configure endpoint groups and endpoints only if you set Type to Standard.
| 3 |
EndpointConfigurations | array<object> | No | The endpoints that are associated with the intelligent routing listener. | |
object | No | The endpoint that is associated with the intelligent routing listener. | ||
Type | string | No | The type of the endpoint that is associated with the intelligent routing listener. Valid values:
You can specify up to 100 endpoint types in the endpoint group that is associated with the intelligent routing listener. For more information, see Service-linked roles. | Ip |
Weight | long | No | The weight of the endpoint that is associated with the intelligent routing listener. Valid values: 0 to 255. You can specify the weights of up to 100 endpoints for an endpoint group of an intelligent routing listener. | 20 |
Endpoint | string | No | The IP address or domain name of the endpoint that is associated with the intelligent routing listener. You can enter the IP addresses or domain names of up to 100 endpoints in an endpoint group that is associated with the intelligent routing listener.
If you set Type to Standard, you can configure endpoint groups and endpoints, and this parameter is required.
| 47.0.XX.XX |
SubAddress | string | No | The private IP address of the ENI.
This parameter is available only when you set the endpoint type to ENI. If you leave this parameter empty, the primary private IP address of the ENI is used.
| 172.168.XX.XX |
EnableClientIPPreservation | boolean | No | Specifies whether to automatically preserve client IP addresses. Valid values:
For more information, see Preserve client IP addresses. | |
EnableProxyProtocol | boolean | No | Specifies whether to use the proxy protocol to preserve client IP addresses. Valid values:
For more information, see Preserve client IP addresses. | |
VpcId | string | No | The virtual private cloud (VPC) ID. You can specify one VPC ID for an endpoint group of an intelligent routing listener.
This parameter is valid and required only if Type is set to IpTarget.
| vpc-bp13r1kpr2lel**** |
VSwitchIds | array | No | The IDs of vSwitches that are deployed in the VPC. | |
string | No | The vSwitch IDs. You can specify two vSwitch IDs for an endpoint group of an intelligent routing listener. | vsw-0jlhcznhw5m7pz2fa**** | |
EndpointRequestProtocol | string | No | The backend service protocol of the endpoint that is associated with the intelligent routing listener. Valid values:
You can specify up to 10 backend service protocols. | HTTP |
EndpointProtocolVersion | string | No | The backend service protocol version of the endpoint that is associated with the intelligent routing listener. Valid values:
You can specify this parameter only if EndpointRequestProtocol is set to HTTPS.
| |
EndpointGroupType | string | No | The type of the endpoint group associated with the intelligent routing listener. Valid values:
You can specify up to 10 endpoint group types. | default |
PortOverrides | array<object> | No | The port mappings. | |
object | No | The port mapping. | ||
ListenerPort | long | No | The listener port that is mapped to the endpoint port. You can specify listener ports in up to five port mappings. | 443 |
EndpointPort | long | No | The endpoint port that is mapped to the listener port. You can specify endpoint ports in up to five port mappings. | 80 |
CustomRoutingEndpointGroupConfigurations | array<object> | No | The endpoint group that is associated with the custom routing listener. The endpoint groups that are associated with the custom routing listener.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| |
object | No | The endpoint group that is associated with the custom routing listener. You can configure up to five endpoint groups for a custom routing listener.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| ||
EndpointGroupRegion | string | No | The region ID of the endpoint group that is associated with the custom routing listener. You can enter the region IDs of up to five endpoint groups.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| cn-hangzhou |
Name | string | No | The name of the endpoint group that is associated with the custom routing listener. The name must be 1 to 128 characters in length and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter. You can specify up to five endpoint group names.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| test |
Description | string | No | The description of the endpoint group that is associated with the custom routing listener. The description can be up to 200 characters in length and cannot contain You can specify up to five endpoint group descriptions.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| test |
DestinationConfigurations | array<object> | No | The mapping configurations of the endpoint group that is associated with the custom routing listener. You need to specify the port ranges and protocols used by the endpoint group. The ports are mapped to listener ports. You can specify up to 20 mapping configurations for an endpoint group of a custom routing listener.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| |
object | No | The mapping configurations of the endpoint group that is associated with the custom routing listener. You need to specify the port ranges and protocols used by the endpoint group. The ports are mapped to listener ports. You can specify up to 20 mapping configurations for an endpoint group of a custom routing listener.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| ||
Protocols | array | No | The protocol used by the endpoint group that is associated with the custom routing listener. You can specify up to four protocol types for an endpoint group of a custom routing listener.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| |
string | No | The backend service protocol of the endpoint group that is associated with the custom routing listener. Valid values:
You can specify up to four protocol types for an endpoint group of a custom routing listener.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| TCP | |
FromPort | integer | No | The start port used by the endpoint group that is associated with the custom routing listener. Valid values: 1 to 65499. The value of FromPort must be equal to or smaller than the value of ToPort. You can specify up to 20 start ports for an endpoint group of a custom routing listener.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| 80 |
ToPort | integer | No | The end port used by the endpoint group that is associated with the custom routing listener. Valid values: 1 to 65499. The value of FromPort must be equal to or smaller than the value of ToPort. You can specify up to 20 end ports for an endpoint group of a custom routing listener.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| 80 |
EndpointConfigurations | array<object> | No | The endpoints that are associated with the custom routing listener. You can configure up to 10 endpoints for an endpoint group of a custom routing listener.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| |
object | No | The endpoint that is associated with the custom routing listener. You can configure up to 10 endpoints for an endpoint group of a custom routing listener.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| ||
Type | string | No | The service type of the endpoint that is associated with the custom routing listener. Default value: PrivateSubNet. Set the value to PrivateSubNet, which specifies a private CIDR block.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| PrivateSubNet |
Endpoint | string | No | The name of the vSwitch attached to the endpoint of the custom routing listener.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| vsw-test01 |
TrafficToEndpointPolicy | string | No | The traffic policy for the endpoint that is associated with the custom routing listener. Default value: DenyAll. Valid values:
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| DenyAll |
PolicyConfigurations | array<object> | No | The destinations in the endpoint that is associated with the custom routing listener. You can specify up to 20 traffic destinations for each endpoint of a custom routing listener.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| |
object | No | The destination in the endpoint that is associated with the custom routing listener. You can specify up to 20 traffic destinations for each endpoint of a custom routing listener.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| ||
Address | string | No | The IP address of the destination. This parameter takes effect only if TrafficToEndpointPolicy is set to AllowCustom. You can specify up to 20 destination IP addresses for each endpoint of a custom routing listener.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| 10.0.XX.XX |
PortRanges | array<object> | No | The port ranges of the destination to which traffic is forwarded. The value of this parameter must fall within the port range of the endpoint group. If you do not specify this parameter, traffic is forwarded over all ports. This parameter takes effect only if TrafficToEndpointPolicy is set to AllowCustom. You can specify port ranges for up to 20 destinations in each endpoint of a custom routing listener. You can specify up to five port ranges for each destination.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| |
object | No | The port range of the destination to which traffic is forwarded. The value of this parameter must fall within the port range of the endpoint group. If you do not specify this parameter, traffic is forwarded over all ports. This parameter takes effect only if TrafficToEndpointPolicy is set to AllowCustom. You can specify port ranges for up to 20 destinations in each endpoint of a custom routing listener. You can specify up to five port ranges for each destination.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| ||
FromPort | integer | No | The start port of the port range. The value of this parameter must fall within the port range of the backend service. This parameter takes effect only if TrafficToEndpointPolicy is set to AllowCustom. You can specify port ranges for up to 20 destinations in each endpoint of a custom routing listener. You can specify up to five start ports for each destination.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| 80 |
ToPort | integer | No | The end port of the destination port range. The value of this parameter must fall within the port range of the backend service. This parameter takes effect only if TrafficToEndpointPolicy is set to AllowCustom. You can specify port ranges for up to 20 destinations in each endpoint of a custom routing listener. You can specify up to five end ports for each destination.
You can configure endpoint groups and endpoints for a custom routing listener only if Type is set to CustomRouting.
| 80 |
IdleTimeout | integer | No | The timeout period of idle connections. Unit: seconds.
| 900 |
RequestTimeout | integer | No | The timeout period for HTTP or HTTPS requests. Unit: seconds. Valid values: 1 to 180. Default value: 60. Unit: seconds.
This parameter takes effect only for HTTP or HTTPS listeners. If the backend server does not respond within the timeout period, GA returns an HTTP 504 error code to the client.
| 15 |
HttpVersion | string | No | The maximum version of the HTTP protocol. Valid values:
Only HTTPS listeners support this parameter.
| http2 |
Response parameters
Examples
Sample success responses
JSON
format
{
"RequestId": "04F0F334-1335-436C-A1D7-6C044FE73368",
"ListenerId": "lsr-bp1bpn0kn908w4nbw****"
}
Error codes
HTTP status code | Error code | Error message | Description |
---|
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | Resource.QuotaFull | The resource quota is exceeded. | The number of resources has reached the upper limit. |
400 | ProtocalIllegal.Listener | The specified listener protocol is invalid. | The specified listener protocol is invalid. |
400 | NotExist.Accelerator | The accelerated instance does not exist. | The GA instance does not exist. |
400 | StateError.Accelerator | The state of the accelerated instance is invalid. | The status of the GA instance is invalid. |
400 | QuotaExceeded.Listener | The maximum number of listeners is exceeded. | The maximum number of listeners is exceeded. |
400 | QuotaExceeded.ListenerPort | The maximum number of listener ports is exceeded. | The maximum number of listener ports is exceeded. |
400 | NotExist.ListenerPort | listener port %s is not exist | - |
400 | PortRangeIllegal.Listener | The specified listener port range is invalid. | The specified listener port range is invalid. |
400 | PortRangeIllegal.Count | The hugePort listener only supports one port range. | The mass port listener (port number greater than 300) only supports one port range. |
400 | PortConflict.Listener | The listener port configuration is in conflict. | The listener port configurations are in conflict. |
400 | PortRangeIllegal.ExceedGaAbility | The listener port range is invalid. For each accelerator instance, you can only create a listener with port range over 300 for each protocol (TCP and UDP). | The listener port range is invalid. For each accelerator instance, you can only create a listener with port range over 300 for each protocol (TCP and UDP). |
400 | PortRangeIllegal.UDP | UDP ports 250, 4789, and 4790 are system reserved ports. | - |
400 | SystemPort.Listener | Ports 65500-65535 are system reserved ports. | Ports 65500 to 65535 are reserved by the system. |
400 | PortRanges.MustOne | The portRanges must be one for HTTPS and HTTP type listener. | Only one port is supported for HTTPS and HTTP type listeners. |
400 | SecurityPolicyId.NotNeed | No security policy ID is required for the listener. | No security policy ID is required for the listener. |
400 | SecurityPolicyIdIllegal.Listener | The listener security policy ID %s is illegal. | The security policy ID of the listener is invalid. |
403 | Forbbiden.SubUser | You are not authorized to operate on the specified resource because your account was created by another user. | The current account is a RAM user and does not have permissions to manage the specified resources. |
403 | Forbidden | The user is not authorized to operate on the specified resource. | The current account does not have permissions to manage the specified resources. |
500 | UnknownError | An error occurred while processing your request. Please try again. If the error persists, please submit a ticket. | An error occurred while the request was being processed. Try again later. |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|
Change time | Summary of changes | Operation |
---|---|---|
2024-12-23 | The Error code has changed. The request parameters of the API has changed | View Change Details |
2024-07-20 | The Error code has changed | View Change Details |
2024-03-27 | The Error code has changed. The request parameters of the API has changed | View Change Details |
2023-11-06 | The Error code has changed. The request parameters of the API has changed | View Change Details |
2023-10-25 | The Error code has changed | View Change Details |
2023-04-20 | The Error code has changed | View Change Details |