laravel 无法加载资源:net::ERR_INCOMPLETE_CHUNKED_ENCODING

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30617841/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 17:02:56  来源:igfitidea点击:

Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING

google-chromelaravelnginxdebianphp-5.6

提问by Sander Koenders

I've been having some problems with my application not loading the views (sometimes). I am running a Debian server with php-fpm and nginx (php5.6.8 and nginx 1.8.0) Both compiled from source. On top of that I am running Lavavel 4.2.

我的应用程序没有加载视图(有时)时遇到了一些问题。我正在运行带有 php-fpm 和 nginx(php5.6.8 和 nginx 1.8.0)的 Debian 服务器,两者都是从源代码编译的。最重要的是,我正在运行 Lavavel 4.2。

So far I've had the problem in both Chrome and Firefox (chrome simply stops loading and shows the error, firefox does not show an error but shows a incomplete version of the view).

到目前为止,我在 Chrome 和 Firefox 中都遇到了问题(chrome 只是停止加载并显示错误,firefox 不显示错误但显示视图的不完整版本)。

So far I've checked the permissions of both nginx and PHP, they both run as the same user (www-data:www-data). My php-fpm socket is configured as:

到目前为止,我已经检查了 nginx 和 PHP 的权限,它们都以相同的用户身份运行(www-data:www-data)。我的 php-fpm 套接字配置为:

[sitename]

listen = /var/run/php5-fpm/sitename.sock
listen.backlog = -1
listen.owner = www-data
listen.group = www-data
listen.mode=0660

; Unix user/group of processes
user = folderuser
group = www-data

; Choose how the process manager will control the number of child processes.
pm = dynamic
pm.max_children = 75
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_requests = 500

; Pass environment variables
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

Note that I set user to folderuser because the folder where the files for the site are located is owned by folderuser (folderuser:www-data). Furthermore, permissions inside laravel folders are configured as 755 (775 for cache and upload folders so that www-data can write cache files)

请注意,我将用户设置为文件夹用户,因为站点文件所在的文件夹归文件夹用户所有(文件夹用户:www-data)。此外,laravel 文件夹内的权限配置为 755(775 用于缓存和上传文件夹,以便 www-data 可以写入缓存文件)

I have disabled any kind of serverside php cache (except for zend opcache).

我已经禁用了任何类型的服务器端 php 缓存(除了 zend opcache)。

I've also tried disabling "prefetch resources to load pages more quickly" feature in chrome, which did not solve the problem.

我还尝试在 chrome 中禁用“预取资源以更快地加载页面”功能,但这并没有解决问题。

As a last resort I've tried this solution:

作为最后的手段,我尝试了这个解决方案:

/*
|--------------------------------------------------------------------------
| Fix for Chrome / PHP 5.4 issue
| http://laravel.io/forum/02-08-2014-another-problem-only-with-chrome
|--------------------------------------------------------------------------
*/

App::after(function($request, $response)
{

    $content = $response->getContent();

    $contentLength = strlen($content);

    $response->header('Content-Length', $contentLength);

});

And some variants to this script, but I got some content length mismatches (more often than the net::ERR_INCOMPLETE_CHUNKED_ENCODINGerrors.

以及这个脚本的一些变体,但我得到了一些内容长度不匹配(比net::ERR_INCOMPLETE_CHUNKED_ENCODING错误更常见。

So to sum up, I've checked permissions and user/group settings serverside, I've disabled serverside caching (except for zend), I've messed around with chrome settings and I've tried a script for laravel, none of which solved the issue I am having. Note that the issue happens at random intervals at random pages on the site.

总而言之,我已经检查了服务器端的权限和用户/组设置,我已经禁用了服务器端缓存(zend 除外),我已经搞砸了 chrome 设置,我已经尝试了一个用于 Laravel 的脚本,但没有一个解决了我遇到的问题。请注意,该问题以随机间隔发生在网站上的随机页面上。

I really do not know what the next step towards solving my problem would be as the solutions above are the only ones I've found on the internet.

我真的不知道解决我的问题的下一步是什么,因为上面的解决方案是我在互联网上找到的唯一解决方案。

I would really appreciate some help.

我真的很感激一些帮助。

Edit:I have a beta version of the same application running off another server with the exact same configuration (only difference is in hardware, more memory though), the issue does not present there.

编辑:我有一个相同应用程序的测试版,它在另一台具有完全相同配置的服务器上运行(唯一的区别是硬件,但内存更多),问题不存在。

Also, I forgot the mention that the application does not run with HTTPS (currently). The beta version however is running with HTTPS.

另外,我忘了提到该应用程序不使用 HTTPS 运行(当前)。但是,测试版使用 HTTPS 运行。

EditThe server where the issue is present has 2048 MB RAM, the beta server has 8192 MB RAM.

编辑存在问题的服务器有 2048 MB RAM,测试版服务器有 8192 MB RAM。

EditI inspected the response with fiddler when the error occured, it simply cuts of the response at some point for no reason.

编辑当错误发生时,我用提琴手检查了响应,它只是在某个时候无缘无故地切断了响应。

回答by DfKimera

You might want to check if the folder /var/lib/nginxis owned by www-datatoo. I had this problem that, when the response page was too big, the Nginx worker process tried to use this folder and failed, because it was owned by nginxand the worker process ran under www-data. By doing chown -R www-data:www-data /var/lib/nginx, the problem was fixed.

您可能想检查该文件夹/var/lib/nginx是否也归其所有www-data。我有这个问题,当响应页面太大,Nginx的工作进程试图用这个文件夹和失败的,因为它是由拥有nginx并根据工作进程跑www-data。通过这样做chown -R www-data:www-data /var/lib/nginx,问题得到了解决。

回答by PersonGuy

I've seen a similar problem on my Nginx Server running on the latest Debian. I'm running a Wordpress site with Advanced Custom Fields installed. On the advanced custom fields it says that the problem could potentially be with the max_input_vars value in the php.ini file. I increased my value from 1000 to 3000 and that fixed the issue on one of my sites.

我在最新的 Debian 上运行的 Nginx 服务器上看到了类似的问题。我正在运行一个安装了高级自定义字段的 Wordpress 站点。在高级自定义字段上,它表示问题可能出在 php.ini 文件中的 max_input_vars 值上。我将我的价值从 1000 增加到 3000,并解决了我的一个网站上的问题。

You can check out this link to see if it might help you. http://www.advancedcustomfields.com/faq/limit-number-fields/

您可以查看此链接,看看它是否对您有所帮助。http://www.advancedcustomfields.com/faq/limit-number-fields/