You need to enable JavaScript to run this app.
导航

CreateListener

最近更新时间2024.04.11 15:34:05

首次发布时间2021.08.31 10:37:27

调用 CreateListener 接口为指定负载均衡实例创建一个监听器。

调试

请求参数

下表中,Tags.N.a类型参数中的“N”表示标签信息的序号,需按照数字顺序从1开始填写,取值范围为1~20。多个标签之间使用&分隔。

名称类型是否必填示例值
描述
ActionStringCreateListener要执行的操作,取值为CreateListener。
VersionString2020-04-01API版本信息,当前版本为:2020-04-01。
LoadBalancerIdStringclb-bp1o94dp5i6ea****负载均衡实例的ID。您可以调用DescribeLoadBalancers接口获取负载均衡实例ID。

ListenerName

String

mylistener

监听器的名称。

  • 必须以字母、数字或中文开头,可包含字母、数字、中文及以下特殊字符:点号(.)、下划线(_)和中划线(-)。
  • 长度限制在1~128字符之间。
  • 不传入该参数或该参数不传入数值时,默认将“协议-端口”作为监听器名称。

Protocol

String

TCP

监听器的协议。取值如下:

  • TCP
  • UDP
  • HTTP
  • HTTPS

Port

Integer

80

监听器接收请求使用的端口,取值范围为1-65535。

说明

如果CLB实例指定了监听端口,则该参数取值必须在CLB实例指定的端口范围内。

Scheduler

String

wrr

监听器使用的调度算法。取值如下:

  • wrr(默认值):加权轮询,权重值越高的后端服务器,被轮询到的次数(概率)越高。
  • wlc:加权最小连接数,在最少连接数的基础上,根据服务器的不同处理能力,给每个服务器分配不同的权重,使其能够接受相应权值数的服务请求。
  • sh:源地址哈希,基于源IP地址的一致性哈希,相同的源地址会调度到相同的后端服务器。

Enabled

String

on

是否启用监听器。取值如下:

  • on:开启(默认值)。
  • off:不开启。

EstablishedTimeout

Integer

800

监听器的连接超时时间,当前仅针对TCP/UDP监听器生效。取值如下:

  • TCP协议:10-900秒,默认为900秒。
  • UDP协议:1-300秒,默认为90秒。

CertificateId

String

cert-bp1o94dp5i6ea****

监听器关联的证书 ID。您可以调用DescribeCertificates接口获取证书ID。

  • 如果监听器协议为HTTPS,此参数为必选。
  • 如果监听器协议为TCP/UDP/HTTP,此参数不生效。
ServerGroupIdStringrsp-bp1o94dp5i6ea****监听器关联的后端服务器组 ID。您可以调用DescribeServerGroups接口获取后端服务器组ID。

AclStatus

String

off

是否开启访问控制功能。

  • on:开启。
  • off:不开启(默认值)。

AclType

String

black

访问控制的方式。取值如下:

  • white:白名单方式。表示监听器仅转发来自所选访问控制策略组中设置的IP地址或地址段的请求。
    如果所选策略组中没有添加任何IP,则监听器不会转发任何请求。
  • black(默认值):黑名单方式。表示仅拒绝来自所选访问控制策略组中设置的IP地址或地址段的请求。
    如果所选策略组中没有添加任何IP,则监听器会转发全部请求。

说明

AclStatus参数配置为 on 时,AclTypeAclIds.N为必填。

Bandwidth

Integer

10

监听器的带宽峰值,单位为Mbps。

  • 默认值为-1,表示监听器不指定限速。此时监听器的带宽峰值默认为CLB实例规格的剩余带宽。
  • 监听器带宽峰值最大不能超过所属CLB实例的规格带宽,CLB实例的规格带宽请参见产品规格

说明

监听器限速功能正在邀测中,如需使用,请联系客户经理。

AclIds.N

String

AclIds.1=acl-3cj44nv0jhhxc6c6rrtet****&AclIds.2=acl-2febxt4pu0zy85oxruw0t****

监听器绑定的访问控制策略组ID。您可以调用DescribeAcls接口获取访问控制策略组ID。

  • 参数 - N:表示访问控制策略组的序号,数量上限为5个。
  • 多个访问控制策略组ID间使用“&”分隔。

说明

AclStatus参数配置为 on 时,AclTypeAclIds.N为必填。

Description

String

This is a listener.

监听器的描述,默认值为空字符串。

  • 必须以字母、数字或中文开头,可包含字母、数字、中文及以下特殊字符:英文逗号(,)、点号(.)、下划线(_)、空格( )、等号(=)、中划线(-)、中文逗号(,)、中文句号(。)。
  • 长度限制为0 ~ 255个字符。

ProxyProtocolType

String

off

是否启用PP协议。取值如下:

  • off(默认值):关闭。
  • standard:开启。

说明

  • 参数Protocol配置为TCP或UDP时,该参数生效。
  • 负载均衡支持PP协议的功能正在邀测中,如需使用,请联系客户经理。

PersistenceType

String

off

会话保持的类型。取值如下:

  • off(默认值):表示不启用会话保持。
  • source_ip:表示源地址IP,仅对TCP/UDP协议生效。

    说明

    该取值正在邀测中,如需使用,请联系客户经理。

  • insert:表示植入Cookie,仅对HTTP/HTTPS协议且Scheduler为“wrr”时生效。
  • server:表示重写Cookie,仅对HTTP/HTTPS协议且Scheduler为“wrr”时生效。

PersistenceTimeout

Integer

10

会话保持的超时时间。单位为秒。默认值为1000秒,取值范围根据参数PersistenceType取值有所不同。

  • PersistenceType配置为source_ip时,取值范围为1~3600。
  • PersistenceType配置为insert时,取值范围为1~86400。

说明

参数PersistenceType配置为source_ip或insert时,该参数生效。

Cookie

String

cookie123

后端服务器配置的会话保持的Cookie名称。

  • 只能包含字母、数字、下划线(_)和中划线(-)。
  • 长度限制在1~200字符之间。

说明

PersistenceType配置为server时,该参数必填,PersistenceType配置为其他值时,该参数不生效。

Http2Enabled

String

off

监听器是否开启前端HTTP 2.0协议。

  • on:开启。
  • off(默认值):不开启。

说明

Protocol配置为HTTPS时,支持配置该参数,否则报错。

Tags.N.Key

String

Tags.1.Key=k1&Tags.2.Key=k2

标签的标签键。

  • 长度限制为1~128个字符。
  • 大小写敏感,不能以volc:sys:的任意大小写组合开头。
  • 不能以空格开头或结尾。
  • 允许包含各国语言文字、数字、空格()、下划线(_)、点号(.)、半角冒号(:)、斜杠(/)、等号(=)、加号(+)、减号(-)和@。

说明

同一资源的标签键不允许重复。如果传入的Tags.N.Key与已有标签的标签键重复,则后添加的标签会覆盖原有标签。

Tags.N.Value

String

Tags.1.Value=v1&Tags.2.Value=v2

标签的标签值。

  • 长度限制为1~256个字符。
  • 大小写敏感,不能以空格开头或结尾。
  • 允许包含各国语言文字、数字、空格()、下划线(_)、点号(.)、半角冒号(:)、斜杠(/)、等号(=)、加号(+)、减号(-)和@。

说明

如果传入该参数,则必须先传入Tags.N.Key

ConnectionDrainEnabled

String

on

监听器是否开启连接优雅中断功能。取值如下:

  • on:开启。
  • off(默认值):不开启。

说明

  • 参数Protocol配置为TCP或UDP时,该参数生效。
  • 该功能正在邀测中,如需使用,请联系客户经理。

ConnectionDrainTimeout

Integer

2

连接优雅中断的超时时间。取值范围为0~900,单位为秒。

  • 参数ConnectionDrainEnabled配置为on时,该参数为必填。
  • 参数ConnectionDrainEnabled配置为off时,该参数默认为0。

HealthCheck.Enabled

String

on

监听器是否开启健康检查功能。

  • on:开启(默认值)。
  • off:不开启。

说明

以下参数仅当本参数的值为 on 时有效。

HealthCheck.IntervalInteger2执行健康检查的时间间隔,取值范围为1 ~ 300 ,默认值为2,单位为秒。

HealthCheck.Timeout

Integer

2

健康检查的响应超时时间,表示如果后端服务器在指定的时间内没有正确响应,则判定为健康检查“异常”。
取值范围为1 ~ 60,默认值为2,单位为秒。

说明

响应超时时间需小于等于检查时间间隔。

HealthCheck.HealthyThreshold

Integer

3

健康检查的健康阈值,表示连续执行指定次数的健康检查,结果均为“正常”的后端服务器将被判定为健康检查“正常”。
取值范围为2 ~ 10,默认值为3,单位为次。

HealthCheck.UnhealthyThreshold

Integer

3

健康检查的不健康阈值,表示连续执行指定次数的健康检查,结果均为“异常”的后端服务器将被判定为健康检查异常。
取值范围为2 ~ 10,默认值为3,单位为次。

HealthCheck.UdpRequest

String

Request123

健康检查的请求字符串。
只允许包含字母和数字,最大长度限制为64个字符。

说明

  • 当参数Protocol配置为UDP,且参数HealthCheck.Enabled配置为on时,该参数生效。
  • 参数HealthCheck.UdpRequestHealthCheck.UdpExpect的取值只能同时为空或同时不为空。

HealthCheck.UdpExpect

String

Expect123

健康检查的预期响应字符串。
只允许包含字母和数字,最大长度限制为64个字符。

说明

  • 当参数Protocol配置为UDP,且参数HealthCheck.Enabled配置为on时,该参数生效。
  • 参数HealthCheck.UdpRequestHealthCheck.UdpExpect的取值只能同时为空或同时不为空。

HealthCheck.Method

String

HEAD

监听器健康检查的方法。取值有以下几种:

  • GET(默认值):服务器需支持GET方法。
  • HEAD:服务器仅返回HEAD头部信息,可以降低后端开销,但要求服务器支持HEAD方法。

说明

当参数Protocol配置为HTTP或HTTPS,且参数HealthCheck.Enabled配置为on时,该参数生效。

HealthCheck.Domain

String

www.test.com

健康检查的域名,需配置为后端服务器上真实对外提供服务的地址。

  • 需至少包含一个点号(.),且不允许以点号(.)开头或结尾。
  • 单个字符串由字母、数字、中划线(-)、点号(.)字符组成,中划线(-)不得出现在字符串的头部或尾部。
  • 长度限制为1 ~ 128个字符。
  • 不传入该参数或该参数不传入数值时,默认为空,表示负载均衡使用各后端服务器的私网IP地址进行健康检查。

说明

当参数Protocol配置为HTTP或HTTPS,且参数HealthCheck.Enabled配置为on时,该参数生效。

HealthCheck.URI

String

/test

健康检查的路径,需配置为后端服务器上真实对外提供服务的地址。

  • 必须以字符‘/’开头。
  • 仅包含字母、数字、中划线(-)、下划线(_)、斜线(/)、点号(.)、百分号(%)、英文问号(?)、#、&、等号(=)字符。
  • 长度限制为1 ~ 128个字符。
  • 不传入该参数或该参数不传入数值时,默认为“/”。

说明

当参数Protocol配置为HTTP或HTTPS,且参数HealthCheck.Enabled配置为on时,该参数生效。

HealthCheck.HttpCode

String

"http_2xx,http_3xx"

健康检查正常的HTTP状态码。取值如下:

  • http_2xx (默认值)
  • http_3xx
  • http_4xx
  • http_5xx
多个状态码间用半角逗号“,”分隔。

说明

当参数Protocol配置为HTTP或HTTPS,且参数HealthCheck.Enabled配置为on时,该参数生效。

返回参数

字段类型示例值
描述
RequestIdString20210811152539010225146063030****请求ID。
ListenerIdStringlsn-2fek3rgsxhrsw5oxruwec****监听器ID。

请求示例

GET /?Action=CreateListener&Version=2020-04-01&AclIds.1=acl-3cj44nv0jhhxc6c6rrtet****&AclStatus=on&AclType=black&Enabled=on&EstablishedTimeout=122&ListenerName=mylistener&LoadBalancerId=clb-bp1o94dp5i6ea****&Port=12&Protocol=TCP&Scheduler=wrr&ServerGroupId=rsp-bp1o94dp5i6ea**** HTTP/1.1
Host: open.volcengineapi.com
Region: cn-beijing
Service: clb

返回示例

{
    "ResponseMetadata": {
        "RequestId": "20210811152539010225146063030****",
        "Action": "CreateListener",
        "Version": "2020-04-01",
        "Service": "clb",
        "Region": "cn-beijing"
    },
    "Result": {
        "RequestId": "20210811152539010225146063030****",
        "ListenerId": "lsn-2fek3rgsxhrsw5oxruwec****"
    }
}

错误码

下表为您列举了该接口与业务逻辑相关的错误码。公共错误码请参见公共错误码文档。

HttpCode错误码错误信息描述

400

MissingParameter

The request is missing a required parameter. Ensure that you have supplied all the required parameters for the request; for example, the 'XXX'.

该请求缺少必要参数。请确保发起请求已提供全部必要参数,比如XXX

说明

其中,XXX表示缺少的参数名称。

400InvalidName.MalformedThe specified Name is malformed.指定的 Name 参数格式不合法。
400InvalidAclStatus.MalformedThe specified AclStatus is malformed.指定的 AclStatus 参数格式不合法。
400InvalidAclType.MalformedThe specified AclType is malformed.指定的 AclType 参数格式不合法。
400InvalidDescription.MalformedThe specified Description is malformed.指定的 Description 参数格式不合法。
400InvalidEnabled.MalformedThe specified Enabled is malformed.指定的 Enabled 参数格式不合法。
400InvalidEstablishedTimeout.MalformedThe specified EstablishedTimeout is malformed.指定的 EstablishedTimeout 参数格式不合法。
400InvalidHealthCheck.Domain.MalformedThe specified HealthCheck.Domain is malformed.指定的 HealthCheck.Domain 参数格式不合法。
400InvalidHealthCheck.Enabled.MalformedThe specified HealthCheck.Enabled is malformed.指定的 HealthCheck.Enabled 参数格式不合法。
400InvalidHealthCheck.HealthyThreshold.MalformedThe specified HealthCheck.HealthyThreshold is malformed.指定的 HealthCheck.HealthyThreshold 参数格式不合法。
400InvalidHealthCheck.HttpCode.MalformedThe specified HealthCheck.HttpCode is malformed.指定的 HealthCheck.HttpCode 参数格式不合法。
400InvalidHealthCheck.Interval.MalformedThe specified HealthCheck.Interval is malformed.指定的 HealthCheck.Interval 参数格式不合法。
400InvalidHealthCheck.Method.MalformedThe specified HealthCheck.Method is malformed.指定的 HealthCheck.Method 参数格式不合法。
400InvalidHealthCheck.Timeout.MalformedThe specified HealthCheck.Timeout is malformed.指定的 HealthCheck.Timeout 参数格式不合法。
400InvalidHealthCheck.URI.MalformedThe specified HealthCheck.URI is malformed.指定的 HealthCheck.URI 参数格式不合法。
400InvalidHealthCheck.UdpExpect.MalformedThe specified HealthCheck.UdpExpect is malformed.指定的 HealthCheck.UdpExpect 参数格式不合法。
400InvalidHealthCheck.UdpRequest.MalformedThe specified HealthCheck.UdpRequest is malformed.指定的 HealthCheck.UdpRequest 参数格式不合法。
400InvalidHealthCheck.UnhealthyThreshold.MalformedThe specified HealthCheck.UnhealthyThreshold is malformed.指定的 HealthCheck.UnhealthyThreshold 参数格式不合法。
400InvalidPort.MalformedThe specified Port is malformed.指定的 Port 参数格式不合法。
400InvalidProtocol.MalformedThe specified Protocol is malformed.指定的 Protocol 参数格式不合法。
400InvalidScheduler.MalformedThe specified Scheduler is malformed.指定的 Scheduler 参数格式不合法。
400InvalidPersistenceTimeout.MalformedThe specified PersistenceTimeout is malformed.指定的 PersistenceTimeout 参数格式不合法。
400InvalidPersistenceType.MalformedThe specified PersistenceType is malformed.指定的 PersistenceType 参数格式不合法。
400InvalidProxyProtocolType.MalformedThe specified ProxyProtocolType is malformed.指定的 ProxyProtocolType 参数格式不合法。
400InvalidBandwidth.MalformedThe specified Bandwidth is malformed.指定的 Bandwidth 参数格式不合法。
400InvalidLoadBalancer.InvalidStatusThe specified LoadBalancer is not in the correct status for the request.指定的负载均衡所处状态无法响应该请求。
400UnsupportedOperation.AccountArrearsThe request on the specified instance is denied due to the account in arrears status.因账户处于欠费状态,对于该实例的操作请求被拒绝。
400QuotaExceed.ListenerNumberEachAclYou've reached the limit on the number of listeners that you can associate.已达到 ACL 可关联的监听器的数量的配额上限。
400QuotaExceed.ListenerNumberEachInstanceYou've reached the limit on the number of listeners that you can create.已达到可创建监听器的数量的配额上限。
400LimitExceeded.AclNumbersYou've reached the limit on the number of ACL that you can associate.已达到可关联的 ACL 的数量上限。
400InvalidServerGroup.LoadBalancerMismatchThe specified ServerGroup and LoadBalancer are not matched.指定的后端服务器组与负载均衡不匹配。
400InvalidLoadBalancerOrAcl.UnSupportActionThe specified LoadBalancer or Acl status does not support this action.指定的负载均衡或者 ACL 状态不支持当前操作。
400InvalidLoadBalancer.UnSupportActionThe specified LoadBalancer does not support this action.指定的负载均衡不支持当前操作。
400InvalidProtocol.ServerGroupIpVersionMismatchThe specified Protocol and ServerGroup IpVersion are not matched.指定的协议与服务器组 IP 版本不匹配。
400InvalidPort.NotAllowedThe specified Port is not allowed.指定的监听器端口不在实例的允许使用范围内。
400InvalidConnectionDrainEnabled.MalformedThe specified ConnectionDrainEnabled is malformed.指定的 ConnectionDrainEnabled 参数格式不合法。
400InvalidConnectionDrainTimeout.MalformedThe specified ConnectionDrainTimeout is malformed.指定的 ConnectionDrainTimeout 参数格式不合法。
400InvalidParameter.ProtocolConflictsToaTypeThe specified Protocol and ToaType conflict.指定的 Protocol 和 ToaType 参数冲突。
400InvalidProject.MalformedThe specified Project is malformed.指定的 Project 参数格式不合法。
400InvalidCookie.MalformedThe specified Cookie is malformed.指定的 Cookie 参数格式不合法。
400InvalidPersistenceType.ProtocolMismatchThe specified PersistenceType and Protocol are not matched.指定的会话保持类型与协议不匹配。
400InvalidPersistenceType.SchedulerMismatchThe specified PersistenceType and Scheduler are not matched.指定的会话保持类型与调度算法不匹配。
400InvalidHttp2Enabled.MalformedThe specified Http2Enabled is malformed.指定的 Http2Enabled 参数格式不合法。
400InvalidHttp2Enabled.ProtocolMismatchThe specified Http2Enabled not match with Protocol.指定的 HTTP2.0 开关与监听器协议类型不一致。
400InvalidIncorrectOrder.MalformedThe specified index order is malformed.指定的索引顺序参数格式不合法。
400InvalidTagKey.MalformedThe specified TagKey is malformed.指定的 TagKey 参数格式不合法。
400InvalidTagValue.MalformedThe specified TagValue is malformed.指定的 TagValue 参数格式不合法。
400LimitExceeded.ServiceManagedTagYou've reached the limit on the number of service managed tags that you can create.已达到单次可创建受管资源标签键值数量的上限。
400LimitExceeded.TagOperationYou've reached the limit on the number of tags that you can operate at a time.已达到单次可操作的标签条目数量上限。
403ForbiddenYou are not authorized to perform operations on the service managed tag.无权限对指定资源打上受管标签。
403InvalidResourceType.ServcieManagedThe specified ResourceType is managed by a service.指定的资源是服务托管资源。
403ForbiddenYou are not authorized to perform operations on the specified service; for example, the 'Bandwidth'.无权限对指定服务进行操作,比如 Bandwidth。
404InvalidLoadBalancer.NotFoundThe specified LoadBalancer does not exist.指定的负载均衡不存在。
404InvalidServerGroup.NotFoundThe specified ServerGroup does not exist.指定的后端服务器组不存在。
404InvalidAcl.NotFoundThe specified ACL does not exist.指定的 ACL 不存在。
404InvalidCertificate.NotFoundThe specified Certificate does not exist.指定的证书不存在。
404InvalidExclusiveCluster.NotFoundThe specified ExclusiveCluster does not exist.指定的独占集群不存在。
409InvalidPort.ConflictThe specified Port already exists.指定的端口已存在。
409InvalidAclId.ConflictThe specified AclId already exists.指定的 ACL 已存在。
412InvalidLoadBalancer.ExpiredThe specified LoadBalancer has expired.指定的负载均衡已过期。
412InvalidExclusiveCluster.ExpiredThe specified ExclusiveCluster has expired.指定的独占集群已过期。
412InvalidExclusiveCluster.UnPurchasedThe specified ExclusiveCluster is not purchased.指定的独占集群未购买。