CreateListener

Last updated: 2020-04-02 18:25:49

PDF

1. API Description

Domain name for API request: clb.tencentcloudapi.com.

This API is used to create a listener for a CLB instance.
This is an async API. After it is returned successfully, you can call the DescribeTaskStatus API with the returned RequestId as an input parameter to check whether this task is successful.

A maximum of 20 requests can be initiated per second for this API.

Note: This API supports Finance regions. If the common parameter Region is a Finance region, a domain name with the Finance region needs to be specified, for example: clb.ap-shanghai-fsi.tencentcloudapi.com

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common parameter. The value used for this API: CreateListener.
Version Yes String Common parameter. The value used for this API: 2018-03-17.
Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
LoadBalancerId Yes String CLB instance ID
Ports.N Yes Array of Integer Specifies for which ports to create listeners. Each port corresponds to a new listener
Protocol Yes String Listener protocol: TCP, UDP, HTTP, HTTPS, or TCP_SSL (which is currently in beta test. If you want to use it, please submit a ticket for application)
ListenerNames.N No Array of String List of names of the listeners to be created. The array of names and array of ports are in one-to-one correspondence. If you do not want to name them now, you do not need to provide this parameter.
HealthCheck No HealthCheck Health check parameter, which is applicable only to TCP/UDP/TCP_SSL listeners
Certificate No CertificateInput Certificate information. This parameter is applicable only to TCP_SSL listeners and HTTPS listeners with the SNI feature not enabled.
SessionExpireTime No Integer Session persistence time in seconds. Value range: 30-3,600. The default value is 0, indicating that session persistence is not enabled. This parameter is applicable only to TCP/UDP listeners.
Scheduler No String Forwarding method of a listener. Value range: WRR, LEAST_CONN.
They represent weighted round robin and least connections, respectively. Default value: WRR. This parameter is applicable only to TCP/UDP/TCP_SSL listeners.
SniSwitch No Integer Whether to enable the SNI feature. This parameter is applicable only to HTTPS listeners

3. Output Parameters

Parameter Name Type Description
ListenerIds Array of String Array of unique IDs of the created listeners
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Creating TCP listeners lis0 and lis1 to listen on ports 7569 and 7570 respectively

This example shows you how to create two TCP listeners which are named lis0 and lis1 and used to listen on ports 7569 and 7570, respectively.

Input Example

https://clb.tencentcloudapi.com/?Action=CreateListener
&LoadBalancerId=lb-cuxw2rm0
&Protocol=TCP
&Ports.0=7569
&Ports.1=7570
&ListenerNames.0=lis0
&ListenerNames.1=lis1
&<Common request parameters>

Output Example

{
  "Response": {
    "ListenerIds": [
      "lbl-d1ubsydq",
      "lbl-4udz130k"
    ],
    "RequestId": "8f272cef-14ff-458c-b67e-1bd21bd2942b"
  }
}

Example2 Setting health check information while creating a TCP listener

Input Example

https://clb.tencentcloudapi.com/?Action=CreateListener
&LoadBalancerId=lb-cuxw2rm0
&Protocol=TCP
&Ports.0=7571
&HealthCheck.HealthSwitch=1
&HealthCheck.TimeOut=5
&HealthCheck.IntervalTime=7
&HealthCheck.HealthNum=4
&HealthCheck.UnHealthNum=4
&<Common request parameters>

Output Example

{
  "Response": {
    "ListenerIds": [
      "lbl-lbbxvq26"
    ],
    "RequestId": "fff13c83-dcb5-481a-ba7c-30e92c276c19"
  }
}

Example3 Creating an HTTPS listener and binding an existing certificate

Input Example

https://clb.tencentcloudapi.com/?Action=CreateListener
&LoadBalancerId=lb-cuxw2rm0
&Protocol=HTTPS
&Ports.0=7572
&Certificate.SSLMode=UNIDIRECTIONAL
&Certificate.CertId=MsJyaXVm
&<Common request parameters>

Output Example

{
  "Response": {
    "ListenerIds": [
      "lbl-4fbxq45k"
    ],
    "RequestId": "db8ae69f-ebda-402b-8d02-ead459aa6ff9"
  }
}

Example4 Creating an HTTPS listener and binding a new certificate

Input Example

https://clb.tencentcloudapi.com/?Action=CreateListener
&LoadBalancerId=lb-cuxw2rm0
&Protocol=HTTPS
&Ports.0=7573
&Certificate.SSLMode=UNIDIRECTIONAL
&Certificate.CertName=my-cert
&Certificate.CertContent=-----BEGIN CERTIFICATE-----
MIIEjTCCA3WgAwIBAgIQA4ZHUAVOv4yrszl3lLfo3TANBgkqhkiG9w0BAQsFADBy
MQswCQYDVQQGEwJDTjElM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example

{
  "Response": {
    "ListenerIds": [
      "lbl-bzfmg9m6"
    ],
    "RequestId": "6082314c-030c-429d-9eae-2dc6b159b5b9"
  }
}

Example5 Creating a UDP listener in the default health check mode of Ping

Input Example

https://clb.tencentcloudapi.com/?Action=CreateListener
&LoadBalancerId=lb-6wlxe9rj
&ListenerNames.0=lis_test
&Protocol=UDP
&Ports.0=432
&HealthCheck.HealthSwitch=1
&<Common request parameters>

Output Example

{
  "Response": {
    "ListenerIds": [
      "lbl-aev333n1"
    ],
    "RequestId": "3b81f03e-6088-448d-abaf-8a487d4f985a"
  }
}

5. Developer Resources

API Explorer

This tool allows online call, signature authentication, SDK code generation and quick search of APIs to greatly improve the efficiency of using TencentCloud APIs.

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
FailedOperation Operation failed.
InternalError Internal error.
InvalidParameter Parameter error.
InvalidParameter.FormatError Wrong parameter format.
InvalidParameterValue Wrong parameter value.
InvalidParameterValue.Length Wrong parameter length.
LimitExceeded Reached quota.
MissingParameter Missing parameter.
ResourceInsufficient Insufficient resource.
UnauthorizedOperation Unauthorized operation.