Modifies the configurations of a TCP listener.

Prerequisites

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes SetLoadBalancerTCPListenerAttribute

The operation that you want to perform.

Set the value to SetLoadBalancerTCPListenerAttribute.

ListenerPort Integer Yes 80

The frontend port that is used by the CLB instance.

Valid values: 1 to 65535.

LoadBalancerId String Yes lb-bp1ygod3yctvg1y****

The ID of the CLB instance.

RegionId String Yes cn-hangzhou

The region ID of the CLB instance.

You can query the region ID from the Regions and zones list or by calling the DescribeRegions operation.

Bandwidth Integer No 43

The maximum bandwidth of the listener. Unit: Mbit/s. Valid values: -1 and 1 to 5120.

  • -1: For a pay-by-data-transfer Internet-facing CLB instance, you can set this parameter to -1. In this case, the bandwidth of the listener is unlimited.
  • 1 to 5120: For a pay-by-bandwidth Internet-facing CLB instance, you can specify the bandwidth limit of each listener. The sum of bandwidth limit values that you set for all listeners cannot exceed the bandwidth limit of the CLB instance.
Scheduler String No wrr

The scheduling algorithm. Valid values:

  • wrr: Backend servers that have higher weights receive more requests than backend servers that have lower weights.
  • rr: Requests are distributed to backend servers in sequence.
  • sch: specifies consistent hashing that is based on source IP addresses. Requests from the same source IP address are distributed to the same backend server.
  • tch: specifies consistent hashing that is based on the following parameters: source IP address, destination IP address, source port, and destination port. Requests that contain the same preceding information are distributed to the same backend server.
Note
  • Only high-performance CLB instances support the sch and tch algorithms.
  • CLB does not support converting the wrr and rr algorithms to sch or tch. You cannot switch the hash algorithm from one to another.
PersistenceTimeout Integer No 0

The timeout period of session persistence. Unit: seconds. Valid values: 0 to 3600.

The default value is 0, which specifies to disable session persistence.

EstablishedTimeout Integer No 500

The timeout period of connections. Unit: seconds.

Valid values: 10 to 900.

HealthyThreshold Integer No 4

The number of health checks that an unhealthy backend server must consecutively pass before it can be declared healthy. In this case, the health check state is changed from fail to success.

Valid values: 2 to 10.

UnhealthyThreshold Integer No 4

The number of health checks that a healthy backend server must consecutively fail before it can be declared unhealthy. In this case, the health check state is changed from success to fail.

Valid values: 2 to 10.

HealthCheckConnectTimeout Integer No 100

The timeout period of a health check response.

If a backend Elastic Compute Service (ECS) instance does not send an expected response within the specified period of time, the ECS instance is considered unhealthy.

Valid values: 1 to 300.

Note If the value of the HealthCheckConnectTimeout parameter is smaller than that of the HealthCheckInterval parameter, the timeout period specified by the HCTimeout parameter is ignored and the period of time specified by the HealthCheckInterval parameter is used as the timeout period.
HealthCheckConnectPort Integer No 8080

The port that is used for health checks.

Valid values: 1 to 65535.

If you do not set this parameter, the port specified by the BackendServerPort parameter is used.

HealthCheckInterval Integer No 5

The time interval between two consecutive health checks. Unit: seconds.

Valid values: 1 to 50.

HealthCheckDomain String No 192.168.0.1

The domain name that is used for health checks. You can set this parameter when the TCP listener requires HTTP health checks. If you do not set this parameter, TCP health checks are performed.

  • $_ip: the private IP address of a backend server.

    If an IP address is specified or the parameter is not set, the CLB instance uses the private IP address of the backend server as the domain name for health checks.

  • domain: The domain name must be 1 to 80 characters in length, and can contain letters, digits, periods (.),and hyphens (-).
HealthCheckURI String No /test/index.html

The uniform resource identifier (URI) that is used for health checks. The URI must be 1 to 80 characters in length, and can contain letters, digits, hyphens (-), forward slashes (/), periods (.), percent signs (%), question marks (?), number signs (#), and ampersands (&). The URI must start with a forward slash (/) but cannot be a single forward slash (/).

You can set this parameter to enable HTTP health checks for the TCP listener.

If this parameter is not set, TCP health checks are performed.

HealthCheckHttpCode String No http_2xx

The HTTP status code that indicates a successful health check. Separate multiple HTTP status codes with commas (,).

Valid values: http_2xx, http_3xx, http_4xx, and http_5xx.

HealthCheckType String No tcp

The type of health checks. Valid values: tcp and http.

SynProxy String No enable

Specifies whether to enable the SynProxy feature of CLB for protection.

Valid values:

  • enable: yes
  • disable: no

We recommend that you use the default value of this parameter.

VServerGroup String No on

Specifies whether to use a vServer group. Valid values:

  • on: yes
  • off: no
Note You cannot set both VserverGroup and MasterSlaveServerGroup to on.
VServerGroupId String No rsp-cige6j5****

The ID of the vServer group.

MasterSlaveServerGroupId String No rsp-cige****

The ID of the primary/secondary server group.

Note You can set only one of the VServerGroupId and MasterSlaveServerGroupId parameters.
MasterSlaveServerGroup String No on

Specifies whether to use a primary/secondary server group. Valid values:

  • on: yes
  • off: no

You cannot set both VserverGroup and MasterSlaveServerGroup to on.

AclId String No 12333

The ID of the access control list (ACL) to be associated with the listener.

If AclStatus is set to on, this parameter is required.

AclType String No white

The type of the ACL. Valid values:

  • white: a whitelist. Only requests from the IP addresses or CIDR blocks in the network ACL are forwarded. Whitelists apply to scenarios where you want to allow only specific IP addresses to access an application. Risks may arise if the whitelist is improperly set. After the whitelist is set, only requests from IP addresses that are added to the whitelist are forwarded by the listener.

    If the whitelist does not contain IP addresses, the CLB listener forwards all requests.

  • black: a blacklist. All requests from the IP addresses or CIDR blocks in the ACL are rejected. Blacklists apply to scenarios where you want to block access from specified IP addresses to an application.

    If no IP address is added to the blacklist, the listener forwards all requests.

Note If AclStatus is set to on, this parameter is required.
AclStatus String No off

Specifies whether to enable the access control feature. Valid values:

  • on: yes
  • off: no
Description String No test

The description of the TCP listener. The description must be 1 to 80 characters in length, and can contain letters, digits, hyphens (-), forward slashes (/), periods (.), and underscores (_).

ConnectionDrain String No off

Specifies whether to enable connection draining. Valid values:

  • on: yes
  • off: no
ConnectionDrainTimeout Integer No 300

The timeout period for connection draining. This parameter is required if ConnectionDrain is set to on. Unit: seconds.

Valid values: 10 to 900.

Response parameters

Parameter Type Example Description
RequestId String CEF72CEB-54B6-4AE8-B225-F876FF7BA984

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/?Action=SetLoadBalancerTCPListenerAttribute
&ListenerPort=80
&LoadBalancerId=lb-bp1ygod3yctvg1y****
&<Common request parameters>

Sample success responses

XML format

<SetLoadBalancerTCPListenerAttributeResponse>
  <RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>
</SetLoadBalancerTCPListenerAttributeResponse>

JSON format

null

Error codes

HttpCode Error code Error message Description
400 InvalidParameterValue.SpecNotSupport The loadBalancer of shared spec does not support the parameter value, %s. The error message returned because shared-resource CLB instances do not support the specified parameters.
400 InvalidParameterValue.RegionNotSupport The region does not support the parameter value, %s. The error message returned because the specified parameter value is not supported in the current region.
400 IpVersionConflict The ip version of this LoadBalancer and the Acl is conflict. The error message returned because the specified IP version is not supported by the ACL.
400 InvalidParameterValue.ZoneNotSupport The zone does not support the parameter value, %s. The error message returned because the specified parameter value is not supported in the current zone.
400 InvalidParameter.ZoneNotSupport The zone does not support the parameter %s. The error message returned because the specified parameter is not supported in the current zone.
400 OperationFailed.ServerGroupInUse The VServerGroup or MasterSlaveServerGroup can not be close for this listener. The error message returned because you cannot disable the server group for the listener.
400 InvalidParam.VServerGroupId The specified VServerGroupId is invalid. The error message returned because VServerGroupId is set to an invalid value. Check the usage notes and change the value accordingly.
400 MissingParam.HealthCheckConnectPort The parameter HealthCheckConnectPort is required. The error message returned because HealthCheckConnectPort is not set.
400 InvalidParam.ListenerPort The specified ListenerPort is invalid. The error message returned because ListenerPort is set to an invalid value. Check the usage notes and change the value accordingly.
400 InvalidParam.StartPort The specified StartPort is invalid. The error message returned because StartPort is set to an invalid value. Check the usage notes and change the value accordingly.
400 InvalidParamSize.PortRange The size of param PortRange is invalid. The error message returned because PortRange is set to an invalid value. Check the usage notes and change the value accordingly.
400 InvalidParam.EndPort The specified EndPort is invalid. The error message returned because EndPort is set to an invalid value. Check the usage notes and change the value accordingly.
400 InvalidParam.PortRange The specified PortRange is invalid. The error message returned because PortRange is set to an invalid value. Check the usage notes and change the value accordingly.
400 QuotaLimitExceeds.AclAttachedToListener %s. The error message returned because the number of listeners associated with the ACL has reached the upper limit.
400 QuotaLimitExceeds.TotalAclEntry %s. The error message returned because the number of ACL rules has reached the upper limit.
400 AclListenerOverLimit %s. %s.
400 Duplicated.AclEntry %s. The error message returned because the specified ACL rule already exists.
400 ResourceNotFound.VServerGroup %s. The error message returned because the specified server group does not exist.
400 IllegalParam.FailoverStrategy The parameter FailoverStrategy is illegal. The error message returned because FailoverStrategy is set to an invalid value. Check the usage notes and change the value accordingly.
400 IllegalParam.FailoverThreshold The parameter FailoverThreshold is illegal. The error message returned because FailoverThreshold is set to an invalid value. Check the usage notes and change the value accordingly.
400 MasterSlaveServerConflict The servers are conflict for MasterSlaveGroup. The error message returned because the backend servers of the primary/secondary server group conflict.
400 MissingParam.VServerGroupId The parameter VServerGroupId is missing. The error message returned because VServerGroupId is not set.
400 OperationDenied.HealthCheckClosedForMasterSlaveMode The operation is denied because of HealthCheckClosedForMasterSlaveMode. The error message returned because health checks must be enabled in primary/secondary mode.
400 InvalidParam.HealthCheck The param of HealthCheck is illegal. The error message returned because HealthCheck is set to an invalid value. Check the usage notes and change the value accordingly.
400 OperationDenied.MasterSlaveGroupLogEnabled The operation is denied because of MasterSlaveGroupLogEnabled. The error message returned because the log feature is enabled for the primary/secondary server group and the operation is rejected.
400 OperationDenied.NotSupportAcl The operation is denied because The single Tunnel or any Tunnel loadbalancer does not support config AccessControlList. The error message returned because Single Tunnel and Any Tunnel CLB instances do not support the ACL.
400 OperationDenied.FullNatModeNotAllowed The operation is not allowed because of FullNatModeNotAllowed. The error message returned because the full NAT mode is not supported.
400 OperationDenied.OnlyIpv4SlbSupport The operation is not allowed because of OnlyIpv4SlbSupport. The error message returned because only IPv4 instances support the full NAT mode.
400 SpecNotSupportParameter The instance with share spec does not support FullNatEnabled parameter. The error message returned because shared-resource instances do not support the FullNatEnabled parameter.

For a list of error codes, visit the API Error Center.