grpc-java icon indicating copy to clipboard operation
grpc-java copied to clipboard

Illegal character in hostname error when using consul and docker

Open raduongithub opened this issue 7 years ago • 5 comments

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.<init>(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.

raduongithub avatar May 24 '18 14:05 raduongithub

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 avatar May 24 '18 15:05 zpencer

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.

zpencer avatar May 24 '18 15:05 zpencer

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

eduardhasanaj avatar Oct 29 '18 12:10 eduardhasanaj

@eduardhasanaj2 just drop the http:// portion.

carl-mastrangelo avatar Oct 29 '18 17:10 carl-mastrangelo

@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

eduardhasanaj avatar Oct 29 '18 18:10 eduardhasanaj