Modifies the configurations of a TCP listener.

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 Server Load Balancer (SLB) instance.

Valid values: 1 to 65535.

LoadBalancerId String Yes lb-bp1ygod3yctvg1y******

The ID of the SLB instance.

RegionId String Yes cn-hangzhou

The ID of the region where the SLB instance is deployed.

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

Bandwidth Integer No 43

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

  • -1: For a pay-by-data-transfer Internet-facing SLB instance, you can set the value to -1. This indicates that the bandwidth is unlimited.
  • 1 to 5120: For a pay-by-bandwidth Internet-facing SLB instance, you can specify a value as the maximum bandwidth for each listener. The sum of maximum bandwidth values that you set for all listeners cannot exceed the maximum bandwidth of the SLB instance.
Scheduler String No wrr

The scheduling algorithm. Valid values:

  • wrr: Backend servers that have higher weights receive more requests than those 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 four factors: source IP address, destination IP address, source port number, and destination port number. Requests that contain the same preceding information are distributed to the same backend server.
Note Only guaranteed-performance SLB instances support sch and tch.
PersistenceTimeout Integer No 0

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

Default value: 0. This indicates that session persistence is disabled.

EstablishedTimeout Integer No 500

The timeout period of connections.

Valid values: 10 to 900. Unit: seconds.

HealthyThreshold Integer No 4

Specifies the number of successful health checks that must be consecutively performed before a backend server can be declared healthy (from fail to success).

Valid values: 2 to 10.

UnhealthyThreshold Integer No 4

Specifies the number of times that a healthy backend server must consecutively fail health checks before it is declared unhealthy (from success to fail).

Valid values: 2 to 10.

HealthCheckConnectTimeout Integer No 100

The time period to wait for 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. Unit: seconds.

Note If the value of the HealthCheckConnectTimeout parameter is smaller than that of the HealthCheckInterval parameter, the value of the HCTimeout parameter is ignored and the value of the HealthCheckInterval parameter is the waiting period.
HealthCheckConnectPort Integer No 8080

The port that is used for health checks.

Valid values: 1 to 65535.

If this parameter is not set, the port specified in BackendServerPort is used for health checks.

HealthCheckInterval Integer No 5

The interval between two consecutive health checks. Valid values: 1 to 50. Unit: seconds.

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 the backend server.

    If an IP address is specified or the parameter is not set, the SLB 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 URL that is used for health checks. The URL 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 URL must not be a single forward slash (/). However, it must start with a forward slash (/).

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.

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 check. Valid values: tcp and http.

SynProxy String No enable

Specifies whether to enable the protection feature SynProxy of SLB.

Valid values:

  • enable: enables the feature.
  • disable: disables the feature.

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 The value of VserverGroup and the value of MasterSlaveServerGroup cannot be set to on at the same time.
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 cannot specify both the vServer group ID and primary/secondary server group ID.
MasterSlaveServerGroup String No on

Specifies whether to use a primary/secondary server group.

Valid values:

  • on: yes
  • off: no

The value of VserverGroup and the value of MasterSlaveServerGroup cannot be set to on at the same time.

AclId String No 12333

The ID of the access control list (ACL) to which the listener is bound.

This parameter is required when the AclStatus parameter is set to on.

AclType String No white

The type of ACL. Valid values:

  • white: specifies the ACL as the whitelist. Only requests from the IP addresses or CIDR blocks in the ACL are forwarded. The whitelist applies to scenarios where you want to allow only specific IP addresses to access an application.

    Risks may occur if the whitelist is improperly set.

    After you set the whitelist, only requests from IP addresses that are added to the whitelist can access the listener.

    After the whitelist is enabled for a listener, if no IP address is added to the whitelist, the listener does not distribute requests.

  • black: specifies the ACL as the blacklist. All requests from the IP addresses or CIDR blocks in the ACL are blocked. The blacklist applies to scenarios where you want to block requests from specific IP addresses to an application.

    If the blacklist is enabled but no IP address is specified in the ACL, the SLB listener distributes all requests.

This parameter takes effect when the AclStatus parameter is set to on.

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 name 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

Specifies the timeout period for the connection draining feature. If ConnectionDrain is set to on, this parameter is required.

Value values: 10 to 900. Unit: seconds.

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>59B41B53-BC4B-481A-9D8D-2A0D20B3FCD1</RequestId>
</SetLoadBalancerTCPListenerAttributeResponse>

JSON format

{
    "RequestId": "59B41B53-BC4B-481A-9D8D-2A0D20B3FCD1"
}

Error codes

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