milvus-sdk-java icon indicating copy to clipboard operation
milvus-sdk-java copied to clipboard

创建连接时uri如果是域名,默认会加上19530

Open tried-code opened this issue 4 months ago • 1 comments

SDK版本:2.6.0 MilvusClientV2 sourceClient = new MilvusClientV2(ConnectConfig.builder() .uri("https://milvus.xiaoying.io") .token("xxxx") .dbName("xxx") .build());

会报错[DEADLINE_EXCEEDED: deadline exceeded after 9.984330316s. Name resolution delay 0.013935956 seconds. [closed=[], open=[[wait_for_ready, buffered_nanos=9994177403, waiting_for_connection],原因是域名未做处理默认会加上19530端口

public URLParser(String url) { try { if (url.startsWith("https://")) { this.secure = true; } URI uri = new URI(url); this.hostname = uri.getHost(); if (Objects.isNull(this.hostname)) { throw new IllegalArgumentException("Missing hostname in url"); } else { this.port = uri.getPort(); if (this.port <= 0) { this.port = 19530; } String path = uri.getPath(); if (!Objects.isNull(path) && !path.isEmpty() && !"/".equals(path)) { this.database = path.substring(1); } else { this.database = null; } } } catch (URISyntaxException e) { throw new IllegalArgumentException("Invalid url: " + url, e); } }

tried-code avatar Aug 14 '25 12:08 tried-code

内部做连接的时候需要host和port,如果没有port,默认视为19530. 比如Zilliz cloud上的服务地址一般是这么写,带了端口号:https://in01-xxxxxxxxxx..vectordb.zillizcloud.com:19535

yhmo avatar Aug 15 '25 02:08 yhmo