Skip to content

fix: Check localhost for grpc connection before other ips #4274

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

Merged
merged 2 commits into from
Jul 14, 2025
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
1 change: 1 addition & 0 deletions doc/changelog.d/4274.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Check localhost for grpc connection before other ips
26 changes: 18 additions & 8 deletions src/ansys/fluent/core/utils/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down