CLOSE_WAIT 这里描述: TCP连接状态
CLOSE_WAIT
此端点已收到来自远程端点的关闭请求,此TCP正在等待来自本地应用程序的连接终止请求。
功能区使用连接池向上游发送请求。每次都会释放连接而不是关闭它以避免建立新连接的开销。
通过配置,池中的连接具有活动时间 ribbon.PoolKeepAliveTime 默认值为15 * 60秒。
ribbon.PoolKeepAliveTime
public class DefaultClientConfigImpl implements IClientConfig { public static final long DEFAULT_POOL_KEEP_ALIVE_TIME = 15 * 60L; public static final TimeUnit DEFAULT_POOL_KEEP_ALIVE_TIME_UNITS = TimeUnit.SECONDS; } public class OkHttpRibbonConfiguration { @Value("${ribbon.client.name}") private String name = "client"; @Configuration protected static class OkHttpClientConfiguration { private OkHttpClient httpClient; @Bean @ConditionalOnMissingBean(ConnectionPool.class) public ConnectionPool httpClientConnectionPool(IClientConfig config, OkHttpClientConnectionPoolFactory connectionPoolFactory) { Integer maxTotalConnections = config.getPropertyAsInteger( CommonClientConfigKey.MaxTotalConnections, DefaultClientConfigImpl.DEFAULT_MAX_TOTAL_CONNECTIONS); Object timeToLiveObj = config .getProperty(CommonClientConfigKey.PoolKeepAliveTime); Long timeToLive = DefaultClientConfigImpl.DEFAULT_POOL_KEEP_ALIVE_TIME; Object ttlUnitObj = config .getProperty(CommonClientConfigKey.PoolKeepAliveTimeUnits); TimeUnit ttlUnit = DefaultClientConfigImpl.DEFAULT_POOL_KEEP_ALIVE_TIME_UNITS; if (timeToLiveObj instanceof Long) { timeToLive = (Long) timeToLiveObj; } if (ttlUnitObj instanceof TimeUnit) { ttlUnit = (TimeUnit) ttlUnitObj; } return connectionPoolFactory.create(maxTotalConnections, timeToLive, ttlUnit); } }