net::ERR_INCOMPLETE_CHUNKED_ENCODING
在浏览器上调用接口,响应被打断了,报错误:net::ERR_INCOMPLETE_CHUNKED_ENCODING
通过IDEA的http接口测试,会报错误:
org.apache.http.ConnectionClosedException: Premature end of chunk coded message body: closing chunk expected
报错解释:
net::ERR_INCOMPLETE_CHUNKED_ENCODING
错误表明浏览器在尝试使用分块传输编码(Chunked Transfer Encoding)读取响应时遇到了问题。分块传输编码是一种传输内容的方法,它将 HTTP 响应分成多个部分,也就是“块”。这种编码方法用于流媒体或者不能立即确定内容大小的情况。
这里的解决方案Google的:
You might want to check if the user that is running the Nginx worker owns the directory /var/lib/nginx
(or /var/cache/nginx
in some distros).
I’ve learned that when you give a response too big for Nginx, it uses this directory to write as a working directory for temporary files. If the worker process cannot access it, Nginx will terminate the transmission before it completes, thus the error INCOMPLETE_CHUNKED_ENCODING
.
另外一种,就是设置buffer:
server {
...
location / {
...
proxy_buffers 8 1024k;
proxy_buffer_size 1024k;
}
}
server {
listen 0000; #//port give by your need
server_name aa.com;
proxy_buffers 16 4k;
proxy_buffer_size 2k;
#charset koi8-r;
#access_log logs/host.access.log main;
location ~ ^/hello/{
proxy_buffering off;
proxy_pass http://127.0.0.1:1111; #//port give by your need
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Connection keep-alive;
}
https://stackoverflow.com/questions/29789268/neterr-incomplete-chunked-encoding-nginx
我们遇到的问题,可能是因为磁盘空间满或者日志文件过大导致。
近期评论