我目前正在一个网站上工作,它会在Google Chrome上引发net::ERR_HTTP2_PROTOCOL_ERROR 200
个错误.我不确定到底是什么引起了这个错误,我只是注意到它只有在使用HTTPS访问网站时才会弹出.我不能百分之百确定它是否相关,但它似乎阻止了JavaScript的正确执行.
例如,发生以下情况:
-
我正在用HTTPS访问这个网站
-
我通过https://publish.twitter.com整合的Twitter feed根本没有加载
-
我可以在控制台中注意到ERR_HTTP2_PROTOCOL_ERROR
-
如果我删除了加载Twitter提要的代码,错误仍然存在
-
如果我使用HTTP访问网站,则会出现Twitter提要,错误也会消失
谷歌Chrome是唯一触发该错误的网络浏览器:它在Edge和Firefox上都运行良好.
(注:我try 过Safari,我有类似的kcferrordomaincfnetwork 303
错误)
我想知道它是否与服务器返回的头相关,因为错误中提到了"200",404/500页不会触发任何东西.
问题是这个错误根本没有记录在案.谷歌搜索给我的结果很少.此外,我注意到它出现在最近的Google Chrome版本中;该错误在v.64.X上不会弹出,但在v.75+上会弹出(不管操作系统是什么,我使用的是Mac tho).
进一步调查的结果如下:
- 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.
谷歌浏览器标题(有错误):
Firefox标题(无错误):
控制台中的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,情况也是如此).