Skip to content

Commit

Permalink
enhance: change connection timeout to clearer msg (#1915)
Browse files Browse the repository at this point in the history
Signed-off-by: yangxuan <[email protected]>
  • Loading branch information
XuanYang-cn authored Mar 1, 2024
1 parent 8572dcd commit 8b02374
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
5 changes: 1 addition & 4 deletions pymilvus/client/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ def is_legal_address(addr: Any) -> bool:


def is_legal_host(host: Any) -> bool:
if not isinstance(host, str):
return False

if len(host) == 0:
if not isinstance(host, str) or len(host) == 0 or (":" in host):
return False

return True
Expand Down
2 changes: 1 addition & 1 deletion pymilvus/client/grpc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def _wait_for_channel_ready(self, timeout: Union[float] = 10):
except grpc.FutureTimeoutError as e:
raise MilvusException(
code=Status.CONNECT_FAILED,
message=f"Fail connecting to server on {self._address}. Timeout",
message=f"Fail connecting to server on {self._address}, illegal connection params or server unavailable",
) from e
except Exception as e:
raise e from e
Expand Down
14 changes: 10 additions & 4 deletions pymilvus/orm/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,17 @@ def __get_full_address(
address, parsed = self.__parse_address_from_uri(uri)
return address, parsed

host = host if host != "" else Config.DEFAULT_HOST
port = port if port != "" else Config.DEFAULT_PORT
self.__verify_host_port(host, port)
_host = host if host != "" else Config.DEFAULT_HOST
_port = port if port != "" else Config.DEFAULT_PORT
self.__verify_host_port(_host, _port)

addr = f"{_host}:{_port}"
if not is_legal_address(addr):
raise ConnectionConfigException(
message=f"Illegal host: {host} or port: {port}, should be in form of '111.1.1.1', '19530'"
)

return f"{host}:{port}", None
return addr, None

def disconnect(self, alias: str):
"""Disconnects connection from the registry.
Expand Down

0 comments on commit 8b02374

Please sign in to comment.