当我们重新加载Nginx Ingress配置时,对于某些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都能正常工作。尝试了许多版本,但似乎仍然存在。