Open
Description
Run up a socks proxy, for example Tor browser proxy on port 9150
Run this code
> import org.asynchttpclient.AsyncHttpClient;
> import org.asynchttpclient.Response;
> import org.asynchttpclient.proxy.ProxyType;
>
> import java.util.concurrent.Future;
>
> import static org.asynchttpclient.Dsl.*;
>
> public class TorDNSIssue {
>
> public static void main(String[] args) throws Exception {
>
> AsyncHttpClient c = asyncHttpClient(config().setProxyServer(proxyServer("localhost", 9150).setProxyType(ProxyType.SOCKS_V5)));
>
> Future<Response> whenResponse = c.prepareGet("http://check.expyuzz4wqqyqhjn.onion").execute();
>
> Response response = whenResponse.get();
>
> System.out.println(response);
>
> }
> }
I get
Exception in thread "main" java.util.concurrent.ExecutionException: java.net.UnknownHostException: check.expyuzz4wqqyqhjn.onion
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:201)
at playpen.sttp.TorDNSIssue.main(TorDNSIssue.java:19)
Caused by: java.net.UnknownHostException: check.expyuzz4wqqyqhjn.onion
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:929)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1324)
at java.net.InetAddress.getAllByName0(InetAddress.java:1277)
at java.net.InetAddress.getAllByName(InetAddress.java:1193)
at java.net.InetAddress.getAllByName(InetAddress.java:1127)
at io.netty.util.internal.SocketUtils$9.run(SocketUtils.java:159)
at io.netty.util.internal.SocketUtils$9.run(SocketUtils.java:156)
at java.security.AccessController.doPrivileged(Native Method)
at io.netty.util.internal.SocketUtils.allAddressesByName(SocketUtils.java:156)
If I point it at https://check.torproject.org/
it works fine
Do I have to do something else to make it not fail?
Thanks