PHP 本地服务器无效请求(意外 EOF)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29141240/
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
PHP local server Invalid request (Unexpected EOF)
提问by Hyman hardcastle
After every execution, regardless of said execution - when using Chrome web browser the PHP local server throws this error:
每次执行后,无论上述执行如何 - 当使用 Chrome 网络浏览器时,PHP 本地服务器会抛出此错误:
Invalid request (Unexpected EOF) \n
无效的请求(意外的 EOF)\n
It's not causing any visible issues; however as it's a persistent issue I was wondering if something may bite me later.
它不会引起任何可见的问题;然而,由于这是一个持续存在的问题,我想知道以后是否会有什么东西会咬我。
Any ideas?
有任何想法吗?
Note: it happens roughly 10 seconds after any page is executed.
Further note:This happens after all executions, even when the files are ended correctly:
注意:它发生在任何页面执行后大约 10 秒。
进一步注意:即使文件正确结束,也会在所有执行后发生这种情况:
<?php echo 'hey'; ?>
would still throw the aforementioned error.
仍然会抛出上述错误。
[Thu Mar 19 09:39:55 2015] 127.0.0.1:53923 [200]: /admin [Thu Mar 19 09:40:05 2015] 127.0.0.1:53924 Invalid request (Unexpected EOF)
[2015 年 3 月 19 日星期四 09:39:55] 127.0.0.1:53923 [200]:/admin [2015 年 3 月 19 日星期四 09:40:05] 127.0.0.1:53924 无效请求(意外 EOF)
This is the full error.
这是完整的错误。
回答by Gary
This is a known bug.
这是一个已知的错误。
From https://bugs.php.net/bug.php?id=60471:
从https://bugs.php.net/bug.php?id=60471:
[2011-12-08 15:01 UTC] lolautruche at gmail dot com Description:
------------
From time to time, built-in server with router script logs this kind of stuff :[Thu Dec 8 13:39:29 2011] 127.0.0.1:50358 Invalid request (Unexpected EOF)
This happens quite randomly, whatever the script has a close tag or not, whatever it has a blank line after close tag or not.
[2011-12-08 15:01 UTC] lolautruche at gmail dot com 描述:
------------
有时,带有路由器脚本的内置服务器会记录此类内容:[2011 年 12 月 8 日星期四 13:39:29] 127.0.0.1:50358 无效请求(意外 EOF)
无论脚本是否有结束标记,无论结束标记后是否有空行,这都是随机发生的。
And the explanation:
和解释:
[2012-02-23 18:45 UTC] michal dot pipa dot xsolve at gmail dot com
...
Chromium has feature called "Predict network actions to improve page load performance" and its enabled by default. It works this way, that if HTML page has links to some resources, than Chromium opens about 10 TCP connections in advance. And then if browser has less than 10 resources to fetch, unused connections times out after 10 seconds. And this (empty payload) causes PHP server to display "Invalid request (unexpected EOF)" message.
[2012-02-23 18:45 UTC] michal dot pipa dot xsolve at gmail dot com
...
Chromium 具有名为“预测网络操作以提高页面加载性能”的功能,并且默认启用。它是这样工作的,如果 HTML 页面有一些资源的链接,那么 Chromium 会提前打开大约 10 个 TCP 连接。然后,如果浏览器要获取的资源少于 10 个,则未使用的连接将在 10 秒后超时。这(空负载)导致 PHP 服务器显示“无效请求(意外 EOF)”消息。
It is a harmless error from the PHP built-in server.
这是来自 PHP 内置服务器的无害错误。
回答by kenorb
This could be related to Chrome specifically and its network prediction feature. So try to disable that feature first. That's why it works for you in Incognito mode, because probably it's disabled in that mode.
这可能与 Chrome 及其网络预测功能有关。因此,请先尝试禁用该功能。这就是它在隐身模式下对您有用的原因,因为它可能在该模式下被禁用。
You can find this option in Chrome Settings and click on 'Show advanced settings'. Should be there in Privacy section.
您可以在 Chrome 设置中找到此选项,然后单击“显示高级设置”。应该在隐私部分。
回答by Gaboik1
On Laravel, I realize this thread hasn't been active for a while now but I found a solution completely unrelated to what other people have been posting. So I realized that I was getting this very error because I didn't have an application key set for my application. You can find out more about application keys in this other Stack Overflow question. Before attempting to generate an application key, make sure you've run the following command in the root directory of your application.
在 Laravel 上,我意识到这个帖子已经有一段时间没有活跃了,但我找到了一个与其他人发布的内容完全无关的解决方案。所以我意识到我收到了这个错误,因为我没有为我的应用程序设置应用程序密钥。您可以在另一个 Stack Overflow 问题中找到有关应用程序密钥的更多信息。在尝试生成应用程序密钥之前,请确保您已在应用程序的根目录中运行以下命令。
composer install
From what I've read, when you create a new application via the
根据我的阅读,当您通过
laravel new application
command, you should have a file called .env
by default. This was not my case, I had to rename the .env.example
file to .env
manually.
Once you have done the two above steps, run this command in the root directory of your app
命令,你应该有一个.env
默认调用的文件。这不是我的情况,我不得不手动将.env.example
文件重命名为.env
。完成上述两个步骤后,在应用程序的根目录中运行此命令
php artisan key:generate
This solved the OP's error for me. Hope it can help someone in the future.
这为我解决了 OP 的错误。希望它可以在未来帮助某人。
回答by rsc
This is bug on PHP. It was fixed on PHP 7.2
这是 PHP 上的错误。它已在 PHP 7.2 上修复
回答by Nolwennig
On Laravel 4.2, I resolve that when I clear the cache with command :
php artisan cache:clear
在 Laravel 4.2 上,当我使用命令清除缓存时,我解决了这个问题:
php artisan cache:clear
Complete list of commands is available with :
php artisan list
完整的命令列表可用于:
php artisan list
回答by Earnie Boyd
I confirmed that @user194714's suggestion is indeed a reason (maybe not the only one though). I'm using WordPress 4.7.1 and changing wp-admin/about.php @ line 55 resolved this issue. More importantly, the page loaded faster after this simple change. I will let WordPress maintainers know.
我确认@user194714 的建议确实是一个原因(虽然可能不是唯一的)。我正在使用 WordPress 4.7.1 并更改 wp-admin/about.php @ line 55 解决了这个问题。更重要的是,这个简单的更改后页面加载速度更快。我会让 WordPress 维护者知道。
回答by Rodrigo Araújo
In my case, I'm using laravel 5.1 + AngularJs and I had removed the route:
就我而言,我使用的是 laravel 5.1 + AngularJs 并且我已经删除了路线:
**Route::get('/', function () {
return view('app');
});**
I put this back and now it works fine.
我把它放回去,现在它工作正常。
回答by Daniel Kukula
I had this error when running PHP on port 9000; after changing it to 8000 the error disappeared.
在端口 9000 上运行 PHP 时出现此错误;将其更改为 8000 后,错误消失了。
回答by codar
I started to encounter this phenomenon just recently with both Firefox and Chrome. I can't confirm nor deny any problems with browser plugins. Since I hadn't change anything in my development environment I started to look for other possibilities. Turns out it was the real time scan engine of the new version of my antivirus program. Once I excluded my project build folders, the php installation folder and php.exe from the scanning the problems with sudden eof occurrences instantly vanished. Maybe this helps some of you.
我最近才开始在 Firefox 和 Chrome 中遇到这种现象。我无法确认或否认浏览器插件的任何问题。由于我没有在我的开发环境中改变任何东西,我开始寻找其他的可能性。原来它是我的防病毒程序新版本的实时扫描引擎。一旦我排除了我的项目构建文件夹,php 安装文件夹和 php.exe 从扫描突然出现的问题时立即消失了。也许这对你们中的一些人有帮助。
回答by mp31415
I see this behaviour when in index.html
我在 index.html 中看到这种行为
<script src="main.js"></script>
is replaced with
被替换为
<script src="main.js" />
(instead of closing </script>
tag its short version is used />
).
(而不是结束</script>
标签,它的简短版本被使用/>
)。