grpc / grpc-java

The Java gRPC implementation. HTTP/2 based RPC
https://grpc.io/docs/languages/java/
Apache License 2.0
11.36k stars 3.82k forks source link

Illegal character in hostname error when using consul and docker #4505

Open raduongithub opened 6 years ago

raduongithub commented 6 years ago

I'm having microservices running in Docker containers and I use Consul as service discovery. Every now and then the GRPC calls between the services are failing and I get this exception:

io.grpc.internal.ProxyDetectorImpl.detectProxy Failed to construct URI for proxy lookup, proceeding without proxy java.net.URISyntaxException: Illegal character in hostname at index 19: https://xxx2_xx-yyy-zzz_1.www2_ppp:8192 at java.net.URI$Parser.fail(URI.java:2848) at java.net.URI$Parser.parseHostname(URI.java:3387) at java.net.URI$Parser.parseServer(URI.java:3236) at java.net.URI$Parser.parseAuthority(URI.java:3155) at java.net.URI$Parser.parseHierarchical(URI.java:3097) at java.net.URI$Parser.parse(URI.java:3053) at java.net.URI.(URI.java:673) at io.grpc.internal.ProxyDetectorImpl.detectProxy(ProxyDetectorImpl.java:128) at io.grpc.internal.ProxyDetectorImpl.proxyFor(ProxyDetectorImpl.java:118) at io.grpc.internal.InternalSubchannel.startNewTransport(InternalSubchannel.java:207) at io.grpc.internal.InternalSubchannel.obtainActiveTransport(InternalSubchannel.java:188) at io.grpc.internal.ManagedChannelImpl$SubchannelImpl.requestConnection(ManagedChannelImpl.java:1130) at io.grpc.PickFirstBalancerFactory$PickFirstBalancer.handleResolvedAddressGroups(PickFirstBalancerFactory.java:79) ...

What version of gRPC are you using?

1.10.0

What did you expect to see?

I would expect that when the DNS name contains non-URI friendly characters, the GRPC call to continue to work and encode the URI properly.

zpencer commented 6 years ago

In this case the gRPC call does continue without a proxy and should work unless the proxy was required. Can you share some more info on the call failures?

I think underscores in URIs is a real issue and gRPC should handle it better.

zpencer commented 6 years ago

Link to some previous discussions about underscores: https://github.com/grpc/grpc-java/issues/3701

Since the RPC should still work, clearing the ticket status until more info is provided.

eduardhasanaj commented 5 years ago

Please can you tell me whats the correct way of typing address of grpc server. I am using this: http://192.169.0.148 but it throw the error anyway

carl-mastrangelo commented 5 years ago

@eduardhasanaj2 just drop the http:// portion.

eduardhasanaj commented 5 years ago

@carl-mastrangelo thank you. I set it like that before but I got connection refused. Remember when starting server localhost domain should not be used, instead use ip address