当Nginx入口重新加载以进行POST时,java Apache HTTP客户端抛出NoHttpResponseException
当我们重新加载Nginx入口配置时,我们会得到一些POST请求的NoHttpResponseException
。这在OkHttp客户端或纯ab -c 100 -n 1000 https://...
中都不会发生
使用最新版本4.5.7,并禁用Gzip压缩以获得可见性。在DefaultHttpResponseParser
中放置一个断点:
@Override
protected HttpResponse parseHead(
final SessionInputBuffer sessionBuffer) throws IOException, HttpException {
//read out the HTTP status string
int count = 0;
ParserCursor cursor = null;
do {
// clear the buffer
this.lineBuf.clear();
final int i = sessionBuffer.readLine(this.lineBuf);
if (i == -1 && count == 0) {
// The server just dropped connection on us
throw new NoHttpResponseException("The target server failed to respond");
}
当发生错误时,我们观察到缓冲区包含以下内容:
0
1.1 200 OK
Server: nginx/1.15.5
Date: Tue, 19 Mar 2019 08:51:27 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Strict-Transport-Security: max-age=15724800; includeSubDomains
10
{"success":true}
但对于常规请求,它有以下内容,这更有意义:
HTTP/1.1 200 OK
Server: nginx/1.15.5
Date: Tue, 19 Mar 2019 08:52:30 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Strict-Transport-Security: max-age=15724800; includeSubDomains
10
{"success":true}
现在,我不确定出了什么问题,因为okhttp和ab都工作正常。尝试了许多版本,但似乎仍然存在
共 (0) 个答案