我遇到了间歇性问题,我没有收到完整的响应实体,所以我最终超时。响应在几毫秒内返回,我看到内容正在被消耗,但它没有达到 Content-Length 标头,因此超时启动。我正在调用的服务由第 3 方拥有,他们说完整的正文是在其中发送的我在请求和响应标头之间看到的时间范围。我是否缺少任何可能导致此类行为的配置?
版本
Java:OpenJDK 11.0.6+10-LTS
HttpAsyncClient:4.1.4
HttpCore-Nio:4.4.13
客户端配置
IOReactorConfig reactorConfig = IOReactorConfig.custom()
.setIoThreadCount(50)
.setSoTimeout(15_000)
.setConnectTimeout(30_000)
.setSoKeepAlive(true)
.setSoLinger(0)
.setSoReuseAddress(true)
.setTcpNoDelay(true)
.build();
DefaultConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(reactorConfig);
SSLIOSessionStrategy sslioSessionStrategy = new SSLIOSessionStrategy(
SSLContext.getDefault(),
new String[] {"TLSv1.2"},
null,
SSLIOSessionStrategy.getDefaultHostnameVerifier()
);
Registry<SchemeIOSessionStrategy> iosessionFactoryRegistry = RegistryBuilder.<SchemeIOSessionStrategy>create()
.register("http", NoopIOSessionStrategy.INSTANCE)
.register("https", sslioSessionStrategy)
.build();
PoolingNHttpClientConnectionManager connectionManager = new PoolingNHttpClientConnectionManager(
ioReactor, null, iosessionFactoryRegistry, null, null, -1, TimeUnit.MILLISECONDS
);
connectionManager.setMaxTotal(1_000);
connectionManager.setDefaultMaxPerRoute(1_000);
CloseableHttpAsyncClient httpAsyncClient = HttpAsyncClients.custom()
.setUserAgent("HttpAsyncClient")
.setConnectionManager(connectionManager)
.build();
电线日志
2021-07-23 14:55:53,999 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.InternalHttpAsyncClient -- {} - [exchange: 33] Connection allocated: CPoolProxy{http-outgoing-32 [ACTIVE]}
2021-07-23 14:55:53,999 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl -- {} - http-outgoing-32 10.187.155.22:26784<->17.000.00.00:443[ACTIVE][r:]: Set attribute http.nio.exchange-handler
2021-07-23 14:55:53,999 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl -- {} - http-outgoing-32 10.187.155.22:26784<->17.000.00.00:443[ACTIVE][rw:]: Event set [w]
2021-07-23 14:55:53,999 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl -- {} - http-outgoing-32 10.187.155.22:26784<->17.000.00.00:443[ACTIVE][rw:]: Set timeout 60000
2021-07-23 14:55:53,999 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.InternalIODispatch -- {} - http-outgoing-32 [ACTIVE]: Connected
2021-07-23 14:55:53,999 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl -- {} - http-outgoing-32 10.187.155.22:26784<->17.000.00.00:443[ACTIVE][rw:]: Set attribute http.nio.http-exchange-state
2021-07-23 14:55:53,999 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.InternalHttpAsyncClient -- {} - [exchange: 33] Start connection routing
2021-07-23 14:55:53,999 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl -- {} - http-outgoing-32 Upgrade session 10.187.155.22:26784<->17.000.00.00:443[ACTIVE][rw:][ACTIVE][rw][NEED_UNWRAP][0][0][174]
2021-07-23 14:55:53,999 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.InternalHttpAsyncClient -- {} - [exchange: 33] route completed
2021-07-23 14:55:53,999 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.MainClientExec -- {} - [exchange: 33] Connection route established
2021-07-23 14:55:53,999 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.MainClientExec -- {} - [exchange: 33] Attempt 1 to execute request
2021-07-23 14:55:54,000 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.MainClientExec -- {} - [exchange: 33] Target auth state: UNCHALLENGED
2021-07-23 14:55:54,000 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.MainClientExec -- {} - [exchange: 33] Proxy auth state: UNCHALLENGED
2021-07-23 14:55:54,000 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl -- {} - http-outgoing-32 10.187.155.22:26784<->17.000.00.00:443[ACTIVE][rw:][ACTIVE][rw][NEED_UNWRAP][0][0][174]: Set timeout 15000
2021-07-23 14:55:54,000 -0700 -- httpasyncclient-33 org.apache.http.headers -- {} - http-outgoing-32 >> POST /path HTTP/1.1
2021-07-23 14:55:54,000 -0700 -- httpasyncclient-33 org.apache.http.headers -- {} - http-outgoing-32 >> Content-Type: application/x-www-form-urlencoded; charset=UTF-8
2021-07-23 14:55:54,000 -0700 -- httpasyncclient-33 org.apache.http.headers -- {} - http-outgoing-32 >> Content-Length: 2244
2021-07-23 14:55:54,000 -0700 -- httpasyncclient-33 org.apache.http.headers -- {} - http-outgoing-32 >> Host: host
2021-07-23 14:55:54,000 -0700 -- httpasyncclient-33 org.apache.http.headers -- {} - http-outgoing-32 >> Connection: Keep-Alive
2021-07-23 14:55:54,000 -0700 -- httpasyncclient-33 org.apache.http.headers -- {} - http-outgoing-32 >> User-Agent: HttpAsyncClient
2021-07-23 14:55:54,000 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl -- {} - http-outgoing-32 10.187.155.22:26784<->17.000.00.00:443[ACTIVE][rw:][ACTIVE][rw][NEED_UNWRAP][0][0][174]: Event set [w]
2021-07-23 14:55:54,075 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.InternalIODispatch -- {} - http-outgoing-32 [ACTIVE] Output ready
2021-07-23 14:55:54,075 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.MainClientExec -- {} - [exchange: 33] produce content
2021-07-23 14:55:54,075 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.MainClientExec -- {} - [exchange: 33] Request completed
2021-07-23 14:55:54,075 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.InternalIODispatch -- {} - http-outgoing-32 [ACTIVE] [content length: 2244; pos: 2244; completed: true]
2021-07-23 14:55:54,076 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl -- {} - http-outgoing-32 10.187.155.22:26784<->17.000.00.00:443[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][2793]: 2764 bytes written
2021-07-23 14:55:54,076 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 >> "POST /path HTTP/1.1[\r][\n]"
2021-07-23 14:55:54,076 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 >> "Content-Type: application/x-www-form-urlencoded; charset=UTF-8[\r][\n]"
2021-07-23 14:55:54,076 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 >> "Content-Length: 2244[\r][\n]"
2021-07-23 14:55:54,076 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 >> "Host: host[\r][\n]"
2021-07-23 14:55:54,076 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 >> "Connection: Keep-Alive[\r][\n]"
2021-07-23 14:55:54,076 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 >> "User-Agent: HttpAsyncClient[\r][\n]"
2021-07-23 14:55:54,076 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 >> "[\r][\n]"
2021-07-23 14:55:54,076 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 >> "..."
2021-07-23 14:55:54,076 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.InternalIODispatch -- {} - http-outgoing-32 [ACTIVE] Request ready
2021-07-23 14:55:54,076 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl -- {} - http-outgoing-32 10.187.155.22:26784<->17.000.00.00:443[ACTIVE][r:w][ACTIVE][r][NOT_HANDSHAKING][0][0][0]: Event cleared [w]
2021-07-23 14:55:54,181 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl -- {} - http-outgoing-32 10.187.155.22:26784<->17.000.00.00:443[ACTIVE][r:r][ACTIVE][r][NOT_HANDSHAKING][0][0][0]: 679 bytes read
2021-07-23 14:55:54,181 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 << "HTTP/1.1 200 OK[\r][\n]"
2021-07-23 14:55:54,181 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 << "Date: Fri, 23 Jul 2021 21:55:54 GMT[\r][\n]"
2021-07-23 14:55:54,181 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 << "Content-Length: 32311[\r][\n]"
2021-07-23 14:55:54,181 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 << "Content-Type: text/xml[\r][\n]"
2021-07-23 14:55:54,181 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 << "id: 3557dfeb-5eaa-a184-aa1a-549c0a6a864b[\r][\n]"
2021-07-23 14:55:54,181 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 << "timestamp: 1627077354171[\r][\n]"
2021-07-23 14:55:54,181 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 << "loggingId: b8b97947a005bc82[\r][\n]"ZyqmZAE1Zyw7ArPVb1xjlQmN3ILL1sgY[\r][\n]"
2021-07-23 14:55:54,181 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 << "[\r][\n]"
2021-07-23 14:55:54,181 -0700 -- httpasyncclient-33 org.apache.http.headers -- {} - http-outgoing-32 << HTTP/1.1 200 OK
2021-07-23 14:55:54,181 -0700 -- httpasyncclient-33 org.apache.http.headers -- {} - http-outgoing-32 << Date: Fri, 23 Jul 2021 21:55:54 GMT
2021-07-23 14:55:54,181 -0700 -- httpasyncclient-33 org.apache.http.headers -- {} - http-outgoing-32 << Content-Length: 32311
2021-07-23 14:55:54,181 -0700 -- httpasyncclient-33 org.apache.http.headers -- {} - http-outgoing-32 << Content-Type: text/xml
2021-07-23 14:55:54,181 -0700 -- httpasyncclient-33 org.apache.http.headers -- {} - http-outgoing-32 << id: 3557dfeb-5eaa-a184-aa1a-549c0a6a864b
2021-07-23 14:55:54,181 -0700 -- httpasyncclient-33 org.apache.http.headers -- {} - http-outgoing-32 << timestamp: 1627077354171
2021-07-23 14:55:54,182 -0700 -- httpasyncclient-33 org.apache.http.headers -- {} - http-outgoing-32 << loggingId: b8b97947a005bc82
2021-07-23 14:55:54,182 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.InternalIODispatch -- {} - http-outgoing-32 [ACTIVE] Response received
2021-07-23 14:55:54,182 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.MainClientExec -- {} - [exchange: 33] Response received HTTP/1.1 200 OK
2021-07-23 14:55:54,183 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.InternalIODispatch -- {} - http-outgoing-32 [ACTIVE] Input ready
2021-07-23 14:55:54,183 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.MainClientExec -- {} - [exchange: 33] Consume content
2021-07-23 14:55:54,183 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl -- {} - http-outgoing-32 10.187.155.22:26784<->17.000.00.00:443[ACTIVE][r:r][ACTIVE][r][NOT_HANDSHAKING][0][0][0]: 0 bytes read
2021-07-23 14:55:54,183 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.InternalIODispatch -- {} - http-outgoing-32 [ACTIVE] [content length: 32311; pos: 0; completed: false]
2021-07-23 14:55:54,183 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.InternalIODispatch -- {} - http-outgoing-32 [ACTIVE] Input ready
2021-07-23 14:55:54,183 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.MainClientExec -- {} - [exchange: 33] Consume content
2021-07-23 14:55:54,183 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl -- {} - http-outgoing-32 10.187.155.22:26784<->17.000.00.00:443[ACTIVE][r:r][ACTIVE][r][NOT_HANDSHAKING][812][0][0]: 15752 bytes read
2021-07-23 14:55:54,183 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 << "..."
2021-07-23 14:55:54,183 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 << "..."
2021-07-23 14:55:54,183 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 << "..."
2021-07-23 14:55:54,186 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl -- {} - http-outgoing-32 10.187.155.22:26784<->17.000.00.00:443[ACTIVE][r:r][ACTIVE][r][NOT_HANDSHAKING][812][0][0]: 0 bytes read
2021-07-23 14:55:54,186 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.InternalIODispatch -- {} - http-outgoing-32 [ACTIVE] [content length: 32311; pos: 15752; completed: false]
2021-07-23 14:55:54,201 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.InternalIODispatch -- {} - http-outgoing-32 [ACTIVE] Input ready
2021-07-23 14:55:54,201 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.MainClientExec -- {} - [exchange: 33] Consume content
2021-07-23 14:55:54,201 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl -- {} - http-outgoing-32 10.187.155.22:26784<->17.000.00.00:443[ACTIVE][r:r][ACTIVE][r][NOT_HANDSHAKING][0][0][0]: 16384 bytes read
2021-07-23 14:55:54,201 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 << "..."
2021-07-23 14:55:54,201 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 << "..."
2021-07-23 14:55:54,201 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 << "..."
2021-07-23 14:55:54,203 -0700 -- httpasyncclient-33 org.apache.http.wire -- {} - http-outgoing-32 << "..."
2021-07-23 14:55:54,203 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl -- {} - http-outgoing-32 10.187.155.22:26784<->17.000.00.00:443[ACTIVE][r:r][ACTIVE][r][NOT_HANDSHAKING][0][0][0]: 0 bytes read
2021-07-23 14:55:54,203 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.InternalIODispatch -- {} - http-outgoing-32 [ACTIVE] [content length: 32311; pos: 32136; completed: false]
2021-07-23 14:56:09,217 -0700 -- httpasyncclient-33 org.apache.http.impl.nio.client.InternalIODispatch -- {} - http-outgoing-32 [ACTIVE] Timeout