Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance: change connection timeout to clearer msg #1915

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading