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:
- The required resource types are displayed in bold characters.
- 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 |
---|---|---|---|---|
ga:CreateListener | create |
|
| none |
Request parameters
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. Note
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 2 to 128 characters in length, and can contain letters, digits, underscores (_), and hyphens (-). The name must start with a letter. | Listener |
Description | string | No | The description of the listener. The description can be at most 200 characters in length. | 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 |
ProxyProtocol | boolean | No | Specifies whether to preserve client IP addresses. Valid values:
Note
This parameter will be deprecated in the API operations that are used to configure listeners. We recommend that you set this parameter when you call API operations to configure endpoint groups. For more information about the ProxyProtocol parameter, see CreateEndpointGroup and UpdateEndpointGroup .
| false |
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. Note
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. Note
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. Note
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
Note
This parameter is available only when you create an HTTPS or HTTP listener.
| false |
XForwardedForGaApEnabled | boolean | No | Specifies whether to use the
Note
This parameter is available only when you create an HTTPS or HTTP listener.
| false |
XForwardedForProtoEnabled | boolean | No | Specifies whether to use the
Note
This parameter is available only when you create an HTTPS or HTTP listener.
| false |
XForwardedForPortEnabled | boolean | No | Specifies whether to use the
Note
This parameter is available only when you create an HTTPS or HTTP listener.
| false |
XRealIpEnabled | boolean | No | Specifies whether to use the
Note
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:
Note
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:
Note
| 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. Note
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 at most 10 endpoint groups for an intelligent routing listener. Note
You can configure endpoint groups and endpoints for an intelligent routing listener only if the Type parameter is set to Standard.
| ||
EndpointGroupName | string | No | The name of the endpoint group that is associated with the intelligent routing listener. The name must be 2 to 128 characters in length, and can contain letters, digits, underscores (_), and hyphens (-). The name must start with a letter. You can enter the names of up to 10 endpoint groups. Note
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 256 characters in length and cannot contain You can enter the descriptions of up to 10 endpoint groups. Note
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 region IDs of up to 10 endpoint groups. Note
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. Note
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. Note
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. Note
You can configure endpoint groups and endpoints only if you set Type to Standard.
| 3 |
HealthCheckPath | string | No | The path to which health check requests are sent. You can specify up to 10 health check paths. Note
You can configure endpoint groups and endpoints only if you set Type to Standard.
| /healthcheck |
HealthCheckPort | long | No | The port that is used for health checks. Valid values: 1 to 65535. You can specify up to 10 health check ports. Note
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. Note
You can configure endpoint groups and endpoints only if you set Type to Standard.
| tcp |
ThresholdCount | long | No | The number of consecutive health check failures that must occur before a healthy endpoint group is considered unhealthy, or the number of consecutive health check successes that must occur before an unhealthy endpoint group is considered healthy. Valid values: 2 to 10. Default value: 3. You can specify the number of successful consecutive health checks or failed consecutive health checks for up to 10 endpoint groups. Note
You can configure endpoint groups and endpoints only if you set Type to Standard.
| 3 |
EndpointConfigurations | array<object> | No | The endpoint that is 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 for an endpoint group of an intelligent routing listener. Note
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. Note
| 20 |
Endpoint | string | No | The IP address or domain name of the endpoint that is associated with the intelligent routing listener. You can specify up to 100 endpoint IP addresses or domain names for an endpoint group of an intelligent routing listener. Note
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 elastic network interface (ENI). Note
If the endpoint type is ENI, you can specify this parameter. If you do not specify this parameter, the primary private IP address of the ENI is used.
| 172.168.XX.XX |
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. Note
| HTTP |
EndpointProtocolVersion | string | No | The backend service protocol version of the endpoint that is associated with the intelligent routing listener. Valid values:
Note
| |
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. Note
| default |
PortOverrides | array<object> | No | The port mapping. | |
object | No | The mappings between ports. | ||
ListenerPort | long | No | The listener port that is mapped to the endpoint port. You can specify up to five listener ports. Note
| 443 |
EndpointPort | long | No | The endpoint port that is mapped to the listener port. You can specify up to five endpoint ports. Note
| 80 |
EnableClientIPPreservationToa | boolean | No | Specifies whether to preserve client IP addresses by using the TCP Option Address (TOA) module. Valid values:
You can specify this parameter for up to 10 endpoint groups. Note
You can configure endpoint groups and endpoints only if you set Type to Standard.
| false |
EnableClientIPPreservationProxyProtocol | boolean | No | Specifies whether to use the proxy protocol to preserve client IP addresses. Valid values:
You can specify this parameter for up to 10 endpoint groups. Note
You can configure endpoint groups and endpoints only if you set Type to Standard.
| false |
CustomRoutingEndpointGroupConfigurations | array<object> | No | The endpoint group that is associated with the custom routing listener. You can configure at most five endpoint groups for a custom routing listener. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| |
object | No | The endpoint group that is associated with the custom routing listener. You can configure at most five endpoint groups for a custom routing listener. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter 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. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter 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 2 to 128 characters in length, and can contain letters, digits, underscores (_), and hyphens (-). The name must start with a letter. You can specify at most five endpoint group names. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| test |
Description | string | No | The description of the endpoint group that is associated with the custom routing listener. The description cannot exceed 256 characters in length and cannot contain You can specify at most five endpoint group descriptions. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter 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 at most 20 mapping configurations for an endpoint group of a custom routing listener. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter 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 at most 20 mapping configurations for an endpoint group of a custom routing listener. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter 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 protocols in each mapping configuration for an endpoint group of a custom routing listener. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| |
string | No | The protocol used by the endpoint group that is associated with the custom routing listener. Valid values:
You can specify up to four protocols in each mapping configuration for an endpoint group of a custom routing listener. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| TCP | |
FromPort | integer | No | The first 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 first ports for an endpoint group of a custom routing listener. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| 80 |
ToPort | integer | No | The last 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 last ports for an endpoint group of a custom routing listener. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| 80 |
EndpointConfigurations | array<object> | No | The endpoint that is associated with the custom routing listener. You can configure at most 10 endpoints for an endpoint group of a custom routing listener. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| |
object | No | The endpoint that is associated with the custom routing listener. You can configure at most 10 endpoints for an endpoint group of a custom routing listener. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| ||
Type | string | No | The service type of the endpoint that is associated with the custom routing listener. Set the value to PrivateSubNet, which specifies a private CIDR block. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| PrivateSubNet |
Endpoint | string | No | The name of the vSwitch that is specified as an endpoint. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| vsw-test01 |
TrafficToEndpointPolicy | string | No | The traffic policy for the endpoint that is associated with the custom routing listener. Valid values:
If you set this parameter to AllowCustom, you must specify IP addresses and port ranges as the destinations to which traffic is distributed. If you specify only IP addresses and do not specify port ranges, GA can forward traffic to the specified IP addresses over all destination ports. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| DenyAll |
PolicyConfigurations | array<object> | No | The destination in the endpoint that is associated with the custom routing listener. You can specify at most 20 destinations in each endpoint of a custom routing listener. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| |
object | No | The destination in the endpoint that is associated with the custom routing listener. You can specify at most 20 destinations in each endpoint of a custom routing listener. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| ||
Address | string | No | The IP address of the destination to which traffic is forwarded. 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. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| 10.0.XX.XX |
PortRanges | array<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 leave this parameter empty, traffic is distributed to all destination 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. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter 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 leave this parameter empty, traffic is distributed to all destination 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. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| ||
FromPort | integer | No | The first port of the destination port range. The value of this parameter must be in the port range of the endpoint group. 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 first ports for each destination. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter is set to CustomRouting.
| 80 |
ToPort | integer | No | The last port of the destination port range. The value of this parameter must be in the port range of the endpoint group. 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. Note
You can configure endpoint groups and endpoints for a custom routing listener only if the Type parameter 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. Note
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:
Note
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 |
---|---|---|---|
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 |
---|---|---|
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 |