Netty DNS resolver fails to resolve computer's name on Windows
See original GitHub issueWhen running on a VM with Windows 10, Netty DNS resolver cannot resolve computer’s name.
Expected behavior
When on Windows, Netty DNS resolver is able to resolve the computer’s name
Actual behavior
The current implementation throws an exception when one tries to resolve the computer’s name
Caused by: java.net.UnknownHostException: failed to resolve 'DESKTOP-BHE9K15' after 2 queries
at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1013)
at io.netty.resolver.dns.DnsResolveContext.tryToFinishResolve(DnsResolveContext.java:966)
at io.netty.resolver.dns.DnsResolveContext.query(DnsResolveContext.java:414)
at io.netty.resolver.dns.DnsResolveContext.tryToFinishResolve(DnsResolveContext.java:938)
at io.netty.resolver.dns.DnsResolveContext.access$700(DnsResolveContext.java:63)
at io.netty.resolver.dns.DnsResolveContext$2.operationComplete(DnsResolveContext.java:467)
Minimal yet complete reproducer code (or URL to code)
public class Application {
public static void main(String[] args) throws Exception {
// JDK
InetAddress[] addresses = InetAddress.getAllByName("DESKTOP-BHE9K15");
System.out.println(Arrays.asList(addresses));
// JDK
InetAddress localhost = InetAddress.getLocalHost();
System.out.println(localhost);
NioEventLoopGroup group = new NioEventLoopGroup();
try {
List<InetSocketAddress> result =
DefaultAddressResolverGroup.INSTANCE
.getResolver(group.next())
.resolveAll(InetSocketAddress.createUnresolved("DESKTOP-BHE9K15", 80))
.get();
System.out.println("Netty DefaultAddressResolverGroup " + result);
DnsNameResolverBuilder builder = new DnsNameResolverBuilder(group.next())
.channelType(NioDatagramChannel.class);
DnsNameResolver resolver = builder.build();
resolver.resolveAll("DESKTOP-BHE9K15")
.get();
}
finally {
group.shutdownGracefully();
}
}
}
when the above code is executed, the result is:
[DESKTOP-BHE9K15/IPv4, DESKTOP-BHE9K15/IPv6]
DESKTOP-BHE9K15/IPv4
Netty DefaultAddressResolverGroup [DESKTOP-BHE9K15/IPv4:80, DESKTOP-BHE9K15/[IPv6]:80]
Exception in thread "main" java.util.concurrent.ExecutionException: java.net.UnknownHostException: failed to resolve 'DESKTOP-BHE9K15' after 2 queries
Netty version
4.1.63.Final
JVM version (e.g. java -version
)
java 11
OS version (e.g. uname -a
)
Windows 10
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Spring Boot API Gateway Unable to resolve name
But I managed to fix this problem by using the reactor.netty.http.client.HttpClient with DefaultAddressResolverGroup.INSTANCE resolver.
Read more >DnsNameResolver xref - Netty
Attempting to send a DNS query or to resolve a domain name will fail once this ... the given hostname is the localhost/host...
Read more >io.netty.resolver.dns.DnsNameResolver - Netty 4.1.72.Final 源码
15 */ 16 package io.netty.resolver.dns; 17 18 import io.netty.bootstrap. ... (Exception ignore) { 150 // Failed to get the system name search domain...
Read more >Troubleshoot the UnknownHostException error in a Java ...
UnknownHostException is a common error message in Java applications. This error typically indicates that there was a DNS resolution failure.
Read more >Vert.x Core Manual
You can also deploy verticles by specifying the verticle name. ... The DNS resolution is always done on the proxy server, to achieve...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep and then apply the solution for
localhost
ok