CreateListener

1. API Description

This API is used to create a load balance listener.

2. Input Parameters

The following request parameter list only provides API request parameters.

Parameter Name
Required
Type
Description

loadBalancerId

Yes

String

Load balance instance ID.

listenerName

Yes

String

Name of the listener to be created.

Only letters, numbers, hyphens (-), and periods (.) are supported, and the beginning and end must be letters or numbers.

healthCheck

No

Parameters related to health check.

If this parameter is not passed or healthCheck.enable = false, the health check will be disabled.

protocol

Yes

Listening protocols.

scheduler

Yes

Listening forwarding rules.

port

Yes

String

Listening port.

Multiple ports are separated by commas.

When the port is a range, connect with -, for example: 10000-10005.

The value range of the port is 1 to 65535.

Please note that the port cannot overlap with other ports of the listener.

3. Output Parameters

Parameter Name
Type
Description

requestId

String

The unique request ID, which is returned for each request. RequestId is required to locate a problem.

listenerId

String

The created listener ID.

4. Code Example

Create a TCP load balance listener to listen to ports 8080-9000 and 8000 without enabling health check.

POST /api/v2/zlb HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateListener
<Common Request Params>

Request:
{
  "loadBalancerId" : "<loadBalancerId>",
  "listenerName" : "sample",
  "protocol" : "TCP",
  "scheduler" : "mh",
  "port" : "8080-9000,8000"
}

Response:
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "listenerId": "<listenerId>"
  }
}

5. Developer Resources

Zenlayer Cloud API 2.0 SDKs to make it easier for you to call APIs. More programming languages will be supported.

6. Error Codes

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

HTTP Status Code
Error code
Description

400

INVALID_LB_STATUS

The load balancer is not in a normal state.

400

INVALID_LISTENER_QUOTA_EXCEED

The number of listeners for the load balancer exceeds the limit.

400

INVALID_PORT_FORMAT_ERROR

Invalid port format.

400

INVALID_LISTENER_PORT_CONFLICT

The port conflicts with other ports of the listener.

400

INVALID_PORT_RANGE

Invalid port range. The port range should be between 1 and 65535.

400

INVALID_LISTENER_PORT_CONFLICT_SELF

The currently configured port is invalid and conflicts with another.

Last updated