Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Stack python3.7 grpcio==1.23.0
When connecting to a target hostname
channel = grpc.insecure_channel('dns:1234') client = dns_pb2_grpc.MyServiceStub(channel) request = dns_pb2.FooRequest() client.Foo(request)
to reproduce, add this to your
This is easy to reproduce, and looks like a kind of bug in the way that we form the uri when creating a channel.
Note that gRPC channels technically require a target string to be a full uri, with a "scheme", "authority", "path" component - e.g. "dns:///foo.com". However, if the "scheme" component is omitted, then we prepend the default "dns" scheme. https://github.com/grpc/grpc/blob/master/doc/naming.md for details. In the insecure channel creation code, the "maybe add default scheme" is basically done in this call:
Internally, that parses the uri and attempts to lookup a "resolver factory" registered for the parsed uri's scheme. If no factory exists, then we prepend the default scheme to the uri and try again, and now use this new prepended target as the server target for the channel. Otherwise, we leave the target as is. I.e. the difference between creating a channel with target:"dns" and target:"dns2" is this code path:
A fix might involve making the URI parser code stricter, and to fail when the target uri doesn't have scheme.
@jossef it would be good to know how bad the impact is of this bug though - is inability to resolve targets of "dns" a blocker for you? I'm actually a little surprised by use of "dns" as a hostname.
The impact is of this bug - an hour of troubleshooting :).
The inability to resolve targets named "dns" is annoying but for me, this is not a blocker. I've worked it around and named it
Until this issue is fixed, suggesting to add a warning for the developer, stating that the hostname "dns" will not resolve due to this issue.
as for the use of the "dns" as a hostname - one of my microservices is a DNS service. this is why.