Chrome net::ERR_INCOMPLETE_CHUNKED_ENCODING 错误 [英] Chrome net::ERR_INCOMPLETE_CHUNKED_ENCODING error

查看:50
本文介绍了Chrome net::ERR_INCOMPLETE_CHUNKED_ENCODING 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的两个月里,我一直在 Chrome 的开发者控制台上收到以下错误:

For the past two months, I have been receiving the following error on Chrome's developer console:

net::ERR_INCOMPLETE_CHUNKED_ENCODING

症状:

  • 页面未加载.
  • 截断的 CSS 和 JS 文件.
  • 页面挂起.

服务器环境:

  • Apache 2.2.22
  • PHP
  • Ubuntu

这发生在我的内部 Apache 服务器上.这不会发生在其他任何人身上 - 即我们的用户都没有遇到这个问题 - 我们开发团队的其他人也没有.

This is happening to me on our in-house Apache server. It is not happening to anybody else - i.e. None of our users are experiencing this problem - nor is anybody else on our dev team.

其他人正在使用完全相同版本的 Chrome 访问完全相同的服务器.我还尝试禁用所有扩展程序并在隐身模式下浏览 - 没有效果.

Other people are accessing the exact same server with the exact same version of Chrome. I have also tried disabling all extensions and browsing in Incognito mode - to no effect.

我使用了 Firefox,并且发生了完全相同的事情.截断的文件等等.唯一的问题是,Firefox 不会引发任何控制台错误,因此您需要通过 Firebug 检查 HTTP 请求以查看问题.

I have used Firefox and the exact same thing is occurring. Truncated files and whatnot. The only thing is, Firefox doesn't raise any console errors so you need to inspect the HTTP request via Firebug to see the problem.

来自 Apache 的响应头:

Response Headers from Apache:

Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:close
Content-Encoding:gzip
Content-Type:text/html; charset=utf-8
Date:Mon, 27 Apr 2015 10:52:52 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Pragma:no-cache
Server:Apache/2.2.22 (Ubuntu)
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Powered-By:PHP/5.3.10-1ubuntu3.8

在测试时,我能够通过在我的 htaccess 文件中强制使用 HTTP 1.0 来解决这个问题:

While testing, I was able to fix the issue by forcing HTTP 1.0 in my htaccess file:

SetEnv downgrade-1.0

这样就解决了这个问题.然而,强制使用 HTTP 1.0 而不是 HTTP 1.1 并不是一个合适的解决方案.

This gets rid of the problem. However, forcing HTTP 1.0 over HTTP 1.1 is not a proper solution.

更新:因为我是唯一遇到此问题的人,所以我认为我需要花更多时间调查这是否是客户端问题.如果我进入 Chrome 的设置并使用恢复为默认值"选项,问题将消失大约 10-20 分钟.然后它返回.

Update: Because I'm the only one experiencing this issue, I figured that I needed to spend more time investigating whether or not it was a client side issue. If I go into Chrome's settings and use the "Restore to Default" option, the problem will disappear for about 10-20 minutes. Then it returns.

推荐答案

该错误试图说明在发送页面时 Chrome 已被切断.您的问题正在尝试找出原因.

The error is trying to say that Chrome was cut off while the page was being sent. Your issue is trying to figure out why.

显然,这可能是影响几个 Chrome 版本的已知问题.据我所知,这是一个问题,这些版本对发送的块的内容长度和该块的表示大小非常敏感(我可能离那个很远).简而言之,一个稍微不完美的标题问题.

Apparently, this might be a known issue impacting a couple of versions of Chrome. As far as I can tell, it is an issue of these versions being massively sensitive to the content length of the chunk being sent and the expressed size of that chunk (I could be far off on that one). In short, a slightly imperfect headers issue.

另一方面,可能是服务器没有发送终端长度为 0 的块.这可能可以用 ob_flush(); 修复.Chrome(或连接或其他东西)也可能很慢.所以当连接关闭时,页面还没有加载.我不知道为什么会发生这种情况.

On the other hand, it could be that the server does not send the terminal 0-length chunk. Which might be fixable with ob_flush();. It is also possible that Chrome (or connection or something) is being slow. So when the connection is closed, the page is not yet loaded. I have no idea why this might happen.

这是偏执程序员的答案:

Here is the paranoid programmers answer:

<?php
    // ... your code
    flush();
    ob_flush();
    sleep(2);
    exit(0);
?>

在您的情况下,可能是脚本超时的情况.我不确定为什么它应该只影响你,但它可能归结为一堆竞争条件?这完全是猜测.您应该能够通过延长脚本执行时间来测试这一点.

In your case, it might be a case of the script timing out. I am not really sure why it should affect only you but it could be down to a bunch of race conditions? That's an utter guess. You should be able to test this by extending the script execution time.

<?php
    // ... your while code
    set_time_limit(30);
    // ... more while code
?>

它也可能像您需要更新 Chrome 安装一样简单(因为此问题是 Chrome 特有的).

It also may be as simple as you need to update your Chrome install (as this problem is Chrome specific).

更新:当 PHP(在同一本地主机上)是 输出缓冲.我想输出被严重破坏而没有多大用处(标题但很少或没有内容).

UPDATE: I was able to replicate this error (at last) when a fatal error was thrown while PHP (on the same localhost) was output buffering. I imagine the output was too badly mangled to be of much use (headers but little or no content).

特别是,我不小心让我的代码递归调用自身,直到 PHP 正确地放弃了.因此,服务器没有发送终端长度为 0 的块——这是我之前发现的问题.

Specifically, I accidentally had my code recursively calling itself until PHP, rightly, gave up. Thus, the server did not send the terminal 0-length chunk - which was the problem I identified earlier.

这篇关于Chrome net::ERR_INCOMPLETE_CHUNKED_ENCODING 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆