From f435bd0d15c3a41f8c635fe645a916fc6c493a8d Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Fri, 11 Jul 2025 11:30:45 -0400 Subject: [PATCH 1/2] fix: Check localhost for grpc connection before other ips --- src/ansys/fluent/core/utils/networking.py | 26 ++++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/ansys/fluent/core/utils/networking.py b/src/ansys/fluent/core/utils/networking.py index 856afdac20c9..930d6c66db98 100644 --- a/src/ansys/fluent/core/utils/networking.py +++ b/src/ansys/fluent/core/utils/networking.py @@ -81,14 +81,24 @@ def find_remoting_ip() -> str: """ from ansys.fluent.core import INFER_REMOTING_IP_TIMEOUT_PER_IP - for addrinfo in socket.getaddrinfo( - "localhost", - 0, - family=socket.AF_INET, - type=socket.SOCK_STREAM, - flags=socket.AI_PASSIVE, - ): - ip = addrinfo[-1][0] + all_ips = [ + addrinfo[-1][0] + for addrinfo in socket.getaddrinfo( + "localhost", + 0, + family=socket.AF_INET, + type=socket.SOCK_STREAM, + flags=socket.AI_PASSIVE, + ) + ] + # Check if we can establish a gRPC connection using localhost first + # before trying other IPs. It has been observed that in some systems, + # although we can establish a test gRPC connection using one of the + # resolved IP addresses in addrinfo, PyFluent fails to connect to Fluent + # using that IP address. Using localhost usually helps in such cases. + all_ips.insert(0, "localhost") + + for ip in all_ips: port = get_free_port() address = f"{ip}:{port}" with _GrpcServer(address): From b5b6b6b926fb31bd8ad558d097c1f8990b6ecba5 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Fri, 11 Jul 2025 15:34:03 +0000 Subject: [PATCH 2/2] chore: adding changelog file 4274.fixed.md [dependabot-skip] --- doc/changelog.d/4274.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/4274.fixed.md diff --git a/doc/changelog.d/4274.fixed.md b/doc/changelog.d/4274.fixed.md new file mode 100644 index 000000000000..599c9bf87d08 --- /dev/null +++ b/doc/changelog.d/4274.fixed.md @@ -0,0 +1 @@ +Check localhost for grpc connection before other ips \ No newline at end of file