java - Vertx HttpClient getNow 不工作

标签 java http vert.x vertx-httpclient

我对 vertx HttpClient 有疑问。 这是显示使用 vertx 和普通 java 测试 GET 的代码。

    Vertx vertx = Vertx.vertx();
    HttpClientOptions options = new HttpClientOptions()
            .setTrustAll(true)
            .setSsl(false)
            .setDefaultPort(80)
            .setProtocolVersion(HttpVersion.HTTP_1_1)
            .setLogActivity(true);
    HttpClient client = vertx.createHttpClient(options);

    client.getNow("google.com", "/", response -> {
        System.out.println("Received response with status code " + response.statusCode());
    });
    System.out.println(getHTML("http://google.com"));

getHTML() 的来源:How do I do a HTTP GET in Java?

这是我的输出:

<!doctype html><html... etc <- correct output from plain java
Feb 08, 2017 11:31:21 AM io.vertx.core.http.impl.HttpClientRequestImpl
SEVERE: java.net.UnknownHostException: failed to resolve 'google.com'.     Exceeded max queries per resolve 3 

但是vertx连接不上。这里出了什么问题?我没有使用任何代理。

最佳答案

供引用:一个解决方案,如this question中所述在 tsegismont 的评论中,将标志 vertx.disableDnsResolver 设置为 true:

-Dvertx.disableDnsResolver=true

为了回退到 JVM DNS 解析器 explained here :

sometimes it can be desirable to use the JVM built-in resolver, the JVM system property -Dvertx.disableDnsResolver=true activates this behavior

我在 kubernetes 环境中观察到 redis 客户端的 DNS 解析问题。

关于java - Vertx HttpClient getNow 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42110790/

相关文章:

java - 终止事件总线并获取结果

java - 如何根据对象更改 JAXB 中 XmlRootElement 的名称?

java - Jena 的 SPARQL 解析错误,但 DBpedia 接受查询

java - 无法使用返回 play.mvc.WebSocket 的方法作为 Play 中请求的处理程序?

从服务器角度进行 HTTP 跟踪

http - 在 POST 后使用 303 重定向以避免 "Webpage has expired": Will it work if there are more bytes than a GET request can handle?

http - 将 Flume JSONHandler 主体作为 JSONObject 发送

kotlin - 我有一个 Vertx 请求,我需要计算一个外部可见(公共(public))URL

java - Vertx 缩放每个线程的实例数

java - 继承和覆盖模块项目中相同bean id的bean属性