我目前正在一个网站上工作,它会在Google Chrome上引发net::ERR_HTTP2_PROTOCOL_ERROR 200个错误.我不确定到底是什么引起了这个错误,我只是注意到它只有在使用HTTPS访问网站时才会弹出.我不能百分之百确定它是否相关,但它似乎阻止了JavaScript的正确执行.

例如,发生以下情况:

  1. 我正在用HTTPS访问这个网站

  2. 我通过https://publish.twitter.com整合的Twitter feed根本没有加载

  3. 我可以在控制台中注意到ERR_HTTP2_PROTOCOL_ERROR

  4. 如果我删除了加载Twitter提要的代码,错误仍然存在

  5. 如果我使用HTTP访问网站,则会出现Twitter提要,错误也会消失

谷歌Chrome是唯一触发该错误的网络浏览器:它在Edge和Firefox上都运行良好. (注:我try 过Safari,我有类似的kcferrordomaincfnetwork 303错误)

我想知道它是否与服务器返回的头相关,因为错误中提到了"200",404/500页不会触发任何东西.

问题是这个错误根本没有记录在案.谷歌搜索给我的结果很少.此外,我注意到它出现在最近的Google Chrome版本中;该错误在v.64.X上不会弹出,但在v.75+上会弹出(不管操作系统是什么,我使用的是Mac tho).


可能和Website OK on Firefox but not on Safari (kCFErrorDomainCFNetwork error 303) neither Chrome (net::ERR_SPDY_PROTOCOL_ERROR)有关


进一步调查的结果如下:

  • error doesn't pop on the exact same page if server returns 404 instead of 2XX
  • 使用HTTPS证书的本地系统不会弹出错误
  • 错误会在使用不同证书的不同服务器(均为OVH)上弹出
  • 无论使用何种PHP版本,从5.6到7.3(使用的框架:Cakephp 2.10)都会弹出错误

As requested, below is the returned header for the failing ressource, which is the whole web page. Even if the error is triggering on each page having a HTTP header 200, those pages are always loading on client's browser, but sometimes an element is missing (in my exemple, the external Twitter feed). Every other asset on the Network tab has a success return, except the whole document itself. line that failed in console

谷歌浏览器标题(有错误):

Chrome header

Firefox标题(无错误):

Firefox header

控制台中的curl --head --http2请求返回以下成功结果:

HTTP/2 200 
date: Fri, 04 Oct 2019 08:04:51 GMT
content-type: text/html; charset=UTF-8
content-length: 127089
set-cookie: SERVERID31396=2341116; path=/; max-age=900
server: Apache
x-powered-by: PHP/7.2
set-cookie: xxxxx=0919c5563fc87d601ab99e2f85d4217d; expires=Fri, 04-Oct-2019 12:04:51 GMT; Max-Age=14400; path=/; secure; HttpOnly
vary: Accept-Encoding

试图更深入地了解chrome://net-export/https://netlog-viewer.appspot.com个工具告诉我请求以RST_流结束:

t=123354 [st=5170]    HTTP2_SESSION_RECV_RST_STREAM
                      --> error_code = "2 (INTERNAL_ERROR)"
                      --> stream_id = 1

因为我在this other post"In HTTP/2, if the client wants to abort the request, it sends a RST_STREAM. When the server receives a RST_STREAM, it will stop sending DATA frames to the client, thereby stopping the response (or the download). The connection is still usable for other requests, and requests/responses that were concurrent with the one that has been aborted may continue to progress. [...] It is possible that by the time the RST_STREAM travels from the client to the server, the whole content of the request is in transit and will arrive to the client, which will discard it. However, for large response contents, sending a RST_STREAM may have a good chance to arrive to the server before the whole response content is sent, and therefore will save bandwidth."中读到的

所描述的行为与我观察到的行为相同.但这意味着浏览器是罪魁祸首,然后我不明白为什么它会发生在两个相同的页面上,一个是200头,另一个是404头(如果我禁用JS,情况也是如此).

推荐答案

我没有弄清楚到底发生了什么,但我找到了解决办法.

CDN feature of OVH美元是罪魁祸首.我在我的主机服务上安装了它,但在我的域中禁用了它,因为我不需要它.

不知何故,当我启用它时,一切都会正常工作.

我认为这迫使Apache使用HTTP2协议,但我不明白的是,在我的每个标题中确实提到了HTTP2,我认为这意味着服务器使用的是正确的协议.

因此,针对我的特殊情况的解决方案是在所有相关域上启用CDN选项.

如果有人能更好地理解这里可能发生的事情,请随意分享解释.

Php相关问答推荐

WooCommerce拆分运输包裹上的商品数量增加运输成本

Laravel中的通配符Undot数组

输入手写CSV时在PHP中进行日期判断

无法在Laravel/Vue停靠容器中启动MySQL

LaravelEloquent 地根据表中的值提取记录

Laveel Livewire Get Groupby姓名列表

PHP-准备用于TCP套接字的数据包

Regex:高级删除单行PHP注释

如何解决 Laravel 外键错误?

在 WooCommerce 中何时何地执行 woocommerce_order_status_completed_notification 挂钩?

启用 WooCommerce 我的帐户付款方式,允许客户添加付款方式

订单完成后创建 WooCommerce 促销代码

将自定义保存金额移至 Woocommerce 简单产品中的价格以下

Laravel 发送邮箱问题 Swift_TransportException

后退按钮不起作用 laravel ajax crud

PHP - 计算非数值数组

根据WooCommerce中选定的变体重量更改输入数量步值

如何用 php ML 解决这个问题?

使用来自 PHP 表单的数据更新 xml 命名空间

在 DomPDF 和 Laravel 中使用内联 css