diff --git a/pymilvus/orm/connections.py b/pymilvus/orm/connections.py index c29863758..88764f081 100644 --- a/pymilvus/orm/connections.py +++ b/pymilvus/orm/connections.py @@ -219,7 +219,7 @@ def add_connection(self, **kwargs): ) """ for alias, config in kwargs.items(): - addr, _ = self.__get_full_address( + addr, parsed_uri = self.__get_full_address( config.get("address", ""), config.get("uri", ""), config.get("host", ""), @@ -234,6 +234,9 @@ def add_connection(self, **kwargs): "user": config.get("user", ""), } + if parsed_uri is not None and parsed_uri.scheme == "https": + alias_config["secure"] = True + self._alias[alias] = alias_config def __get_full_address( @@ -366,7 +369,6 @@ def connect_milvus(**kwargs): ) kwargs.pop("password") kwargs.pop("token", None) - kwargs.pop("secure", None) kwargs.pop("db_name", "") self._connected_alias[alias] = gh diff --git a/tests/test_connections.py b/tests/test_connections.py index 9e2a01203..fc5b23975 100644 --- a/tests/test_connections.py +++ b/tests/test_connections.py @@ -361,7 +361,7 @@ def test_issue_1196(self): config = {"alias": alias, "host": "localhost", "port": "19531", "user": "root", "password": 12345, "secure": True} connections.connect(**config) config = connections.get_connection_addr(alias) - assert config == {"address": 'localhost:19531', "user": 'root'} + assert config == {"address": 'localhost:19531', "user": 'root', "secure": True} connections.add_connection(default={"host": "localhost", "port": 19531}) config = connections.get_connection_addr("default") @@ -370,4 +370,4 @@ def test_issue_1196(self): connections.connect("default", user="root", password="12345", secure=True) config = connections.get_connection_addr("default") - assert config == {"address": 'localhost:19531', "user": 'root'} + assert config == {"address": 'localhost:19531', "user": 'root', "secure": True}