简体   繁体   中英

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. 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?

  2. How is the timeout triggered?

I'm using https://vertx.io/docs/apidocs/io/vertx/core/http/HttpClientRequest.html

In general, not related to Vert.x:
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. Probably your question is about WebClientOptions , that indeed provides different timeouts:
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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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