Ruby-on-rails net::ERR_INCOMPLETE_CHUNKED_ENCODING 仅在 Chrome 中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22608564/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
net::ERR_INCOMPLETE_CHUNKED_ENCODING in Chrome only
提问by StefanDorresteijn
I've been getting this error when loading certain pages:
加载某些页面时出现此错误:
net::ERR_INCOMPLETE_CHUNKED_ENCODING
These pages don't do anything special and everything seems to work in other browsers. The pages that this happens on display data in JSON. It only happens when the JSON page has to display a large amount of items. The rails console is not displaying any errors (200 response).
这些页面没有做任何特别的事情,而且一切似乎都可以在其他浏览器中运行。发生这种情况的页面以 JSON 格式显示数据。它仅在 JSON 页面必须显示大量项目时发生。rails 控制台未显示任何错误(200 响应)。
回答by gavin1986
I have met this problem yesterday. It's because of the server didn't response some resources.
我昨天遇到了这个问题。这是因为服务器没有响应某些资源。
In my page, i have some large file links like<a href="/file_path">file_name</a>,
and this happend only in chrome.
在我的页面中,我有一些大文件链接,例如<a href="/file_path">file_name</a>,而这仅发生在 chrome 中。
In a while ,I recognized this maybe caused by the chrome's 'Predict network actions to improve page load performance' feature.So I turned off this feature in chrome://settingsand try it again. As expected, the error didn't occur again.
过了一会儿,我意识到这可能是由 chrome 的“预测网络操作以提高页面加载性能”功能引起的。所以我关闭了这个功能,chrome://settings然后再试一次。正如预期的那样,错误没有再次发生。
After that, I changed resource links with full_url_path instead of relative_path(in rails, use resource_url instead of resource_path), then I didn't have to turn off the chrome's feature. And it looks good.
之后,我使用 full_url_path 而不是 relative_path 更改了资源链接(在 Rails 中,使用 resource_url 而不是 resource_path),然后我不必关闭 chrome 的功能。它看起来不错。
回答by bjdmeest
I had this with a Wordpress website, also only in Chrome.
我在 Wordpress 网站上有这个,也只有在 Chrome 中。
Updating the website and its plugins to the latest version didn't help, and other people didn't seem to have the same problem when visiting the website, but then I saw this post, turned off my antivirus (avast) real-time shields, as suggested, and the problem went away.
将网站及其插件更新到最新版本没有帮助,其他人在访问网站时似乎也没有出现同样的问题,但后来我看到了这个帖子,关闭了我的防病毒(avast)实时防护,正如建议的那样,问题就消失了。
NOTE: The Real-Time Protection on some of the various anti-virus programs (AVAST, Kapersky and ESET) seem to be a major cause of this error.
注意:某些各种防病毒程序(AVAST、Kapersky 和 ESET)的实时保护似乎是导致此错误的主要原因。
回答by eightyfive
In my case, the problem was cache-related and was happening when doing a CORS request.
就我而言,问题与缓存有关,并且在执行 CORS 请求时发生。
As stated in comments above:
如上面的评论所述:
the error seemed to appear randomly
错误似乎是随机出现的
This is because of the Http cache system.
这是因为 Http 缓存系统。
Forcing the response header Cache-Controlto no-cacheresolved my issue:
强制响应报头Cache-Control,以no-cache解决我的问题:
[ using Symfony HttpFoundationcomponent ]
[使用 Symfony HttpFoundation组件]
<?php
$response->headers->add(array(
'Cache-Control' => 'no-cache'
));
回答by Herr Nentu'
I had this in a symfony project (PHP).
我在一个 symfony 项目(PHP)中有这个。
Like you describe your issue I had some static page (html.twig) with simple HTML and CSS... so nothing special about it.
就像你描述你的问题一样,我有一些带有简单 HTML 和 CSS 的静态页面(html.twig)......所以没有什么特别之处。
For me it was a mod_rewrite problem, after I enabled mod_rewrite and added FallbackResource /index.phpto my vhost it all worked smoothly.
对我来说,这是一个 mod_rewrite 问题,在我启用 mod_rewrite 并将其添加FallbackResource /index.php到我的 vhost 后,它一切顺利。
PS: if you have apache lower than 2.2.16 create a .htaccess file in your root folder and use this code:
PS:如果您的 apache 低于 2.2.16,请在您的根文件夹中创建一个 .htaccess 文件并使用以下代码:
Options -MultiViews
RewriteEngine On #RewriteBase /path/to/app RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L] </IfModule>
选项 - 多视图
RewriteEngine On #RewriteBase /path/to/app RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L] </IfModule>
回答by Jorgeeadan
If having problems with symfony4 apache2, take a look at this answer
如果symfony4 apache2有问题,请查看此答案
as summary, you have to disable FallbackResource/index.phpinto your virtualhost configuration file, next, you may want to run composer install symfony/apache-bundleand fix your /etc/apache2/apache.confchanging AllowOverride nonefor AllowOverride All, in order to enable the .htaccess file created in the installation recipe run, at the end, by restarting apache2 service (sudo service apache2 restart) the site must load without /index.php at the end of the URI.
作为总结,你必须禁用FallbackResource/index.php到您的虚拟主机配置文件,然后,你可能要运行composer install symfony/apache-bundle和修复你/etc/apache2/apache.conf改变AllowOverride none为AllowOverride All通过重新启动的Apache2服务,以便能够在安装配方运行中创建.htaccess文件,在结束时,(sudo service apache2 restart) 站点必须在 URI 末尾没有 /index.php 的情况下加载。
Hope this helps someone!
希望这可以帮助某人!
回答by Fedir RYKHTIK
We had net::ERR_INCOMPLETE_CHUNKED_ENCODINGproblem in case of HTML, which contained too much empty lines. Some browsers had difficulties with interpretation of long files.
我们net::ERR_INCOMPLETE_CHUNKED_ENCODING在 HTML 的情况下遇到了问题,其中包含太多空行。一些浏览器在解释长文件时遇到困难。
Once we've made code cleaning in our templates by cleaning the code from empty lines, error disappeared.
一旦我们通过从空行中清理代码来清理模板中的代码,错误就消失了。
回答by sunny
This error comes, if you have relationship among domain objects or model object which you are returning back to Jquery. Please annotate with @JsonBackReference, your issue will be resolved
如果您要返回给 Jquery 的域对象或模型对象之间存在关系,则会出现此错误。请使用@JsonBackReference 进行注释,您的问题将得到解决
@ManyToOne(fetch = FetchType.LAZY,cascade=CascadeType.ALL)
@JoinColumn(name = "parentId", nullable = false)
@JsonBackReference
public Parent getParent() {
return this.parent;
}
@OneToMany(cascade=CascadeType.ALLfetch =FetchType.LAZY,mappedBy=
"parent")
@JsonBackReference
public Set<Category> getChild() {
return this.child;
}
回答by Saon Mukherjee
Please check your radware load balancer configuration. The setting for “FastView” and “APM” features can cause this issue. In my case it will get fixed after disabling those.
请检查您的 radware 负载平衡器配置。“FastView”和“APM”功能的设置可能会导致此问题。在我的情况下,它会在禁用这些后得到修复。
回答by chandrashekar mothkula
If you have opened any streams for the response those must be closed. For example code if you have opened a ServletOutputStream to download the zip directory the stream need to be closed as follows.
如果您为响应打开了任何流,则必须关闭这些流。例如,如果您打开了 ServletOutputStream 以下载 zip 目录,则需要按如下方式关闭该流。
ServletOutputStream sos = response.getOutputStream();
response.setContentType("application/zip");
response.setHeader("Content-Disposition", "attachment;filename=project.ZIP");
sos.write(zip);
sos.flush();
sos.close();
回答by Anton
I've catched the same error on a local website. In logs I found this record:
我在本地网站上发现了同样的错误。在日志中我找到了这个记录:
"nginx failed (13: Permission denied) while reading upstream, client: 127.0.0.1".
My decision through restart of nginx and php-fpm from the right user:
我通过从正确的用户重新启动 nginx 和 php-fpm 做出的决定:
Let's my_user – main user of website's directory.
让我们 my_user - 网站目录的主要用户。
First, go to nginx.conf: Change
首先进入nginx.conf:更改
user nginx; -> user my_user my_user_group;
or paste this
或粘贴这个
user my_user my_user_group;
on the top of file
在文件顶部
2) Second, in php5/fpm/pool.d/www.conf
2)其次,在php5/fpm/pool.d/www.conf
# Find and change this variables from old -> to new:
user -> my_user
group -> my_user
listen.owner -> my_user
listen.group -> my_user
3) And finally you need restart of nginx and php-fpm. Then make chown 0700 in handmode for /var/lib/nginx/tmp for my_user, like this:
3)最后你需要重启nginx和php-fpm。然后在手动模式中为 my_user 为 /var/lib/nginx/tmp 制作 chown 0700,如下所示:
chown -R my_user:my_user 0700 /var/lib/nginx/tmp

