Skip to content
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

Receiving Unknown Status code on hostname with InetSocketAddres #6954

Closed
emaayan opened this issue Apr 21, 2020 · 8 comments · Fixed by #7023
Closed

Receiving Unknown Status code on hostname with InetSocketAddres #6954

emaayan opened this issue Apr 21, 2020 · 8 comments · Fixed by #7023

Comments

@emaayan
Copy link

emaayan commented Apr 21, 2020

What version of gRPC-Java are you using?

version 1.24.2

What is your environment?

Windows 10/2012/2016, Ubuntu 16, openJDK 8.242

What did you expect to see?

Status code unavailable

What did you see instead?

Status code unknown

Steps to reproduce the bug

used :
NettyChannelBuilder.forAddress(new InetSocketAddress(address,443))
where address contains a hostname that does not exists
got back StatusRuntimeExcetpion with cause of UnresolvedAddressException and code Unknown

@emaayan emaayan added the bug label Apr 21, 2020
@emaayan
Copy link
Author

emaayan commented Apr 21, 2020

request by:
https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/grpc-io/YGq4zfR-zdU/qr1rVi5_AwAJ

@ejona86
Copy link
Member

ejona86 commented Apr 29, 2020

The problem here is the InetSocketAddress is unresolved, which I don't think we'll ever support. forAddress(SocketAddress) is intended for use in cases something "weird" is going on, like you are using Unix Domain Sockets. I strongly encourage you to use the forAddress(String, port) method instead.

The full status returned:

Status{code=UNKNOWN, description=null, cause=java.nio.channels.UnresolvedAddressException
	at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel.checkResolvable(AbstractEpollChannel.java:336)
	at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel.doConnect(AbstractEpollChannel.java:706)
	at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.connect(AbstractEpollChannel.java:562)
	at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.connect(DefaultChannelPipeline.java:1342)
	at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:548)
	at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:533)
	at io.grpc.netty.shaded.io.netty.channel.ChannelDuplexHandler.connect(ChannelDuplexHandler.java:54)
	at io.grpc.netty.shaded.io.grpc.netty.WriteBufferingAndExceptionHandler.connect(WriteBufferingAndExceptionHandler.java:150)
	at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:548)
	at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.access$1000(AbstractChannelHandlerContext.java:61)
	at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext$9.run(AbstractChannelHandlerContext.java:538)
	at io.grpc.netty.shaded.io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
	at io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
	at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)

Looks like we should just special-case the exception in Utils.statusFromThrowable.

@ejona86 ejona86 added this to the Next milestone Apr 29, 2020
@emaayan
Copy link
Author

emaayan commented Apr 30, 2020 via email

@ejona86
Copy link
Member

ejona86 commented Apr 30, 2020

Want to send a PR?

FWIW, we do say:

This factory method is primarily intended for using Netty Channel types other than SocketChannel. forAddress(String, int) should generally be preferred over this method, since that API permits delaying DNS lookups and noticing changes to DNS.

We told you "don't use it for this purpose" and we also said it doesn't support "noticing change to DNS." In this case DNS resolution has already been performed and failed, so it will just be permanently broken.

The documentation for InetSocketAddress itself says that unresolved addressed are in a sort of pseudo-broken mode, "If resolution fails then the address is said to be unresolved but can still be used on some circumstances like connecting through a proxy," and gives no guidance for when they may actually work.

I completely agree we should improve the error though to be UNAVAILABLE.

@emaayan
Copy link
Author

emaayan commented Apr 30, 2020 via email

@ejona86
Copy link
Member

ejona86 commented Apr 30, 2020

Yeah, it is the shading causing the trouble. Javadoc works on source and shading works on class files, so there's no way to let the javadoc process the shaded results.

It's here:

* Creates a new builder with the given server address. This factory method is primarily intended
* for using Netty Channel types other than SocketChannel. {@link #forAddress(String, int)} should
* generally be preferred over this method, since that API permits delaying DNS lookups and
* noticing changes to DNS.

Note that "unresolved" only has meaning for InetSocketAddress, so we'd have to say something more like "if you pass an unresolved InetSocketAddress" instead of "if you pass an unresolved socket address".

@reggiemcdonald
Copy link
Contributor

I'm interested in working on this if nobody else wants to?

@ejona86
Copy link
Member

ejona86 commented May 7, 2020

@reggiemcdonald, nobody is working on this to my knowledge. Go for it!

@ejona86 ejona86 modified the milestones: Next, 1.31 Jul 7, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants