Skip to content

improvement: throw explicit error when creating channel manually via forAddress()#1191

Open
theorangeguo wants to merge 1 commit into
grpc-ecosystem:masterfrom
theorangeguo:topic/xcg/explicit-error-for-ip-address
Open

improvement: throw explicit error when creating channel manually via forAddress()#1191
theorangeguo wants to merge 1 commit into
grpc-ecosystem:masterfrom
theorangeguo:topic/xcg/explicit-error-for-ip-address

Conversation

@theorangeguo

Copy link
Copy Markdown

When creating a gRPC channel manually using forAddress(host, port) with a raw IP, the URI defaults to the discovery scheme because DiscoveryClientResolverFactory registers with a high priority (Priority=6).

This causes the DiscoveryClient to attempt resolving the IP address as a service name, leading to a misleading "No servers found" error.

This commit adds a validation check to:

  1. Detect if the service name is a raw IP address.
  2. Throw an explicit IllegalArgumentException with actionable advice.
  3. Guide users to use .forTarget("dns:///...") instead of .forAddress() to bypass the high-priority discovery resolver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant