From b89d1ebf906d247ba7341b1eba155d5dc248f3e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyelusion=E2=80=9D?= Date: Mon, 16 Oct 2023 18:06:43 +0800 Subject: [PATCH] fix only cloud serverless cluster port must be 443. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: “yelusion” --- .../milvus/common/constant/MilvusClientConstant.java | 2 ++ src/main/java/io/milvus/param/ConnectParam.java | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/milvus/common/constant/MilvusClientConstant.java b/src/main/java/io/milvus/common/constant/MilvusClientConstant.java index a297505dd..61986c4e3 100644 --- a/src/main/java/io/milvus/common/constant/MilvusClientConstant.java +++ b/src/main/java/io/milvus/common/constant/MilvusClientConstant.java @@ -6,6 +6,8 @@ public static class MilvusConsts { public final static String HOST_HTTPS_PREFIX = "https://"; public final static String HOST_HTTP_PREFIX = "http://"; + + public final static String CLOUD_SERVERLESS_URI_REGEX = "^https://in03-.{20,}zilliz.*.com$"; } public static class StringValue { public final static String COLON = ":"; diff --git a/src/main/java/io/milvus/param/ConnectParam.java b/src/main/java/io/milvus/param/ConnectParam.java index 4fbe89ef7..50986f1c5 100644 --- a/src/main/java/io/milvus/param/ConnectParam.java +++ b/src/main/java/io/milvus/param/ConnectParam.java @@ -28,6 +28,10 @@ import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.concurrent.TimeUnit; +import java.util.regex.Pattern; + +import static io.milvus.common.constant.MilvusClientConstant.MilvusConsts.CLOUD_SERVERLESS_URI_REGEX; +import static io.milvus.common.constant.MilvusClientConstant.MilvusConsts.HOST_HTTPS_PREFIX; /** * Parameters for client connection. @@ -353,12 +357,15 @@ protected void verify() throws ParamException { this.databaseName = result.getDatabase(); } + if(host.startsWith(HOST_HTTPS_PREFIX)){ + this.secure = true; + } + if (StringUtils.isNotEmpty(token)) { this.authorization = Base64.getEncoder().encodeToString(String.format("%s", token).getBytes(StandardCharsets.UTF_8)); - if (!token.contains(":")) { + if (Pattern.matches(CLOUD_SERVERLESS_URI_REGEX, this.uri)) { this.port = 443; } - this.secure = true; // } if (port < 0 || port > 0xFFFF) {