简体   繁体   English

java中不同http客户端超时时间单位的意义

[英]Significance of time units for different http client timeouts in java

I was wondering what's the significance of different units of time used while specifying http client timeouts.我想知道在指定 http 客户端超时时使用的不同时间单位有什么意义。 Connection Timeout is in milliseconds, idle timeout in seconds, and read-timeout in milliseconds.连接超时以毫秒为单位,空闲超时以秒为单位,读取超时以毫秒为单位。

  1. Does vertx use different precisions to determine the accuracy with which the timeout should be triggered? vertx 是否使用不同的精度来确定触发超时的准确度?

  2. How is the timeout triggered?超时是如何触发的?

I'm using https://vertx.io/docs/apidocs/io/vertx/core/http/HttpClientRequest.html我正在使用https://vertx.io/docs/apidocs/io/vertx/core/http/HttpClientRequest.html

In general, not related to Vert.x:一般来说,与 Vert.x 无关:
connection timeout < read timeout < idle timeout connection timeout < read timeout < idle timeout
More specifically, to check if connection is idle may take tens on milliseconds.更具体地说,检查连接是否空闲可能需要数十毫秒。 Hence it's not optimal to allow setting this values in milliseconds in the first place, since then there may be situations when time to check idle connection is greater than idle timeout.因此,首先允许以毫秒为单位设置此值并不是最佳选择,因为可能会出现检查空闲连接的时间大于空闲超时的情况。

HttpClientRequest provides only one timeout. HttpClientRequest仅提供一种超时。 Probably your question is about WebClientOptions , that indeed provides different timeouts:可能您的问题是关于WebClientOptions ,它确实提供了不同的超时:
https://vertx.io/docs/apidocs/io/vertx/ext/web/client/WebClientOptions.html https://vertx.io/docs/apidocs/io/vertx/ext/web/client/WebClientOptions.html

If you're interested in how it's actually used, you can take a look at NetClientImpl source code:如果您对它的实际使用方式感兴趣,可以查看NetClientImpl源代码:

https://github.com/eclipse-vertx/vert.x/blob/master/src/main/java/io/vertx/core/net/impl/NetClientImpl.java#L103 https://github.com/eclipse-vertx/vert.x/blob/master/src/main/java/io/vertx/core/net/impl/NetClientImpl.java#L103

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM