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) {