Netty HttpClient 中的 maxIdleTime 和 maxLifeTime 有什么区别?

What is the difference between maxIdleTime and maxLifeTime in Netty HttpClient?

根据documentation

maxIdleTime - The time after which the channel is eligible to be closed when idle (resolution: ms). Default: max idle time is not specified.

maxLifeTime - The total life time after which the channel is eligible to be closed (resolution: ms). Default: max life time is not specified.

如果我这样定义 ConnectionProvider,我的连接何时会关闭?

ConnectionProvider.builder("fixed")
    .maxIdleTime(Duration.ofSeconds(20))
    .build() 

20秒后?至少在 20 秒后?

如果我这样定义呢?

ConnectionProvider.builder("fixed")
    .maxLifeTime(Duration.ofSeconds(20))
    .build() 

有什么区别,我应该期待什么?

maxLifeTime 定义连接的最长生命周期。例如,与负载均衡器的连接不应总是重复使用,因为它的 IP 地址因资源变化而发生变化,因此新连接应基于基础 DNS 更新以新 IP 结束。

maxIdleTime 定义连接的最大空闲时间。例如,空闲时间20分钟后,连接将被关闭。