CreateListener

Last updated: 2020-10-16 18:26:28

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

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

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
TargetType No String Target real server type. NODE: binding a general node; TARGETGROUP: binding a target group.
SessionType No String Session persistence type. Valid values: Normal: the default session persistence type; QUIC_CID: session persistence by QUIC connection ID. The QUIC_CID value can only be configured in UDP listeners. If this field is not specified, the default session persistence type will be used.
KeepaliveEnable No Integer Whether to enable a persistent connection (This parameter can only be configured in HTTP/HTTPS listeners). Valid values: 0: no; 1: yes. Default value: 0

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 a UDP listener with the default Ping health check

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-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"
  }
}

Example2 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"
  }
}

Example3 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"
  }
}

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

This example shows you how to create two TCP listeners lis0 and lis1 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"
  }
}

Example5 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=-----BEGINCERTIFICATE-----\nMIIEjTCCA3WgAwIBAgIQA4ZHUAVOv4yrszl3lLfo3TANBgkqhkiG9w0BAQsFADBy\nMQswCQYDVQQGEwJDTjElMCMGA1UEChMcVHJ1c3RBc2lhIFRlY2hub2xvZ2llcywg\nSW5jLjEdMBsGA1UECxMURG9tYWluIFZhbGlkYXRlZCBTU0wxHTAbBgNVBAMTFFRy\ndXN0QXNpYSBUTFMgUlNBIENBMB4XDTE4MDEwOTAwMDAwMFoXDTE5MDEwOTEyMDAw\nMFowFjEUMBIGA1UEAxMLZmx5Zmx5Lm5hbWUwggEiMA0GCSqGSIb3DQEBAQUAA4IB\nDwAwggEKAoIBAQClpnigB7r3ahv7BMuQw9KzB9Yfq3p+cRUbX9EMRyri2GrJbmrP\npESP8XQuIn4MZESvePR0r4gGHAHVri8nXzyQw6/m77BT/fIf4cQtEyz61gopDlYq\nbLTAKVfGFhGVikvQPoItOYbA9/l2YwtDENl8wBhcFrghWTRifnFSC0bNPj1ot5eu\nL8x5UOZLSa9kaQCm2/RQUBii5w3YBh+HmJgb7HPs8OoHKVScBo6eAyOcr+HNrA8W\n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PjVpYuEQCJZvUjrhd+LJRubTTUXIHFLAoGAU0KJp/KwaNB5aDgERXG9kbU9\nKEYz+YMSTZbSS1mduKR/2uc7DUxKP3kcRWjW2y8xSZ/VViXqhXLSAzp/x+qAIjzA\n0lnQHFDf6oxO+3HNsCZCWnpr04yvO+S8jT8GG0LnmASWMVzU8Ppsbq0qlmXW0fhh\nvIW0IvX6vkXB+FgHmYECgYBrsJe5P4QYV2oVrP8xGL78T51uY89tyTwWZSbtTmdY\nUsG8+wNjgh6iF8EUY5usG1ztdq58ob+5lcf/FeKJTfI56yjnKDXfxToycYwjhbVA\nEv0ZQYXPOwOGjmbXEklC1aqV4nlL5enQ2KMCtWeqM/KE4H3JyvZYbeRaEv9pNoFO\nRwKBgBs+g0d81ufZSuTBlxfivDwrNV6LNzrgnwsTn+H/T7MfyoIEkT3nSGjanQHF\nwzPYyUpQx5OzNZp1ZEzKeW3GXVWjK+bfKlA7fmrZwDa8/JR6kTfCmc3WRrrQ92yq\nlFRW1kinLCP5y56SJEBz+DRSYV7ql9wOHyaM23sHkbCF0HAa\n-----ENDRSAPRIVATEKEY-----
&<Common request parameters>

Output Example

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

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 Incorrect parameter value.
InvalidParameterValue.Length Wrong parameter length.
LimitExceeded Quota exceeded.
MissingParameter Missing parameter.
ResourceInsufficient Insufficient resources.
UnauthorizedOperation Unauthorized operation.

Was this page helpful?

Was this page helpful?

  • Not at all
  • Not very helpful
  • Somewhat helpful
  • Very helpful
  • Extremely helpful
Send Feedback
Help