jetty webclient中的默认idleTimeout是什么?

时间:2019-07-11 18:57:35

标签: java jetty httpclient

我们正在使用Spring Reactive WebClient进行http调用。它在下面使用JettyClientHttpConnector。向外部服务器发出请求时,间歇性地开始引发EOF异常。

经过一些在线挖掘,发现该连接似乎已被服务器关闭。但是我找不到码头网络客户端使用的默认idleTimeout是什么。我希望在将固定值添加到生产代码并将其破坏之前,先了解idletimeout的值

return webclient.post()
        .uri(url)
        .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
        .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
        .syncBody(request)
        .retrieve()
        .bodyToMono(responseType)

        });

No exception handler found for exception java.io.EOFException: HttpConnectionOverHTTP@78adba37::DecryptedEndPoint@39cf23c5{sfp-prod-1.infra.marcus.com/10.207.63.102:3128\u003c-\u003e/10.255.50.84:36250,OPEN,fill=-,flush=C,to=416480/0}
        at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.earlyEOF(HttpReceiverOverHTTP.java:338) [jetty-client-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1551) ~[jetty-http-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.shutdown(HttpReceiverOverHTTP.java:209) [jetty-client-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:147) [jetty-client-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:73) [jetty-client-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:133) [jetty-client-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:155) [jetty-client-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305) [jetty-io-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [jetty-io-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onFillable(SslConnection.java:411) [jetty-io-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:305) [jetty-io-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:159) [jetty-io-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [jetty-io-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118) [jetty-io-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333) [jetty-util-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310) [jetty-util-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168) [jetty-util-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126) [jetty-util-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366) [jetty-util-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765) [jetty-util-9.4.14.v20181114.jar:9.4.14.v20181114]
        at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683) [jetty-util-9.4.14.v20181114.jar:9.4.14.v20181114]
        at java.lang.Thread.run(Thread.java:748) [na:1.8.0_192]

1 个答案:

答案 0 :(得分:0)

让我们看看异常顶部的三行。

首先,您有...

  

未找到异常java.io.EOFException的异常处理程序:   HttpConnectionOverHTTP @ 78adba37 :: DecryptedEndPoint @ 39cf23c5 {sfp-prod-1.infra.marcus.com/10.207.63.102:3128\u003c-\u003e/10.255.50.84:36250,OPEN,fill =-,flush = C,to = 416480/0}

这告诉我们您有一个OPEN连接,没有过早关闭。

下一行...

  

org.eclipse.jetty.client.http.HttpReceiverOverHTTP.earlyEOF(HttpReceiverOverHTTP.java:338)[jetty-client-9.4.14.v20181114.jar:9.4.14.v20181114]

告诉我们您的EOF处于早期状态,通常表明您HTTP协议失败。

  

org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1551)〜[jetty-http-9.4.14.v20181114.jar:9.4.14.v20181114]

此行以代码形式告诉我们,您的客户端正在从另一端解析HTTP响应,该响应使用的是“块式” Transfer-Encoding,它解析了最后的关闭块0\r\n\r\n,但是读取缓冲区包含更多字节,这违反了HTTP规范。

WebClient通过EarlyEOF告诉您HTTP协议已到达EOF,但仍有未读取的数据。 这种情况还意味着该连接上的HTTP协议无效,并且必须强制关闭该连接。

此状态,连接已关闭,关闭块丢失后的数据被报告为EOFException。