2

net::ERR_HTTP2_PROTOCOL_ERROR

 1 year ago
source link: https://easeapi.com/blog/162-http2-protocol-error.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

net::ERR_HTTP2_PROTOCOL_ERROR / 2022-12-01

Ajax请求出现错误net::ERR_HTTP2_PROTOCOL_ERROR,定位为CDN配置不合理造成。

本周遇到了Ajax请求出现错误net::ERR_HTTP2_PROTOCOL_ERROR的问题。具体的错误表现为:

  • 请求耗时较大时容易复现;
  • 针对上传特定文件类型容易复现;
  • 浏览器控制台中仅提示net::ERR_HTTP2_PROTOCOL_ERROR错误,没有收到API的响应数据;
  • 发生错误时,业务请求在服务端没有收到错误日志,且业务流程正常完成。

起初认为就是简单的Ajax请求超时问题,但在修改设置后问题依旧。后续又检查了Nginx、php等各种环境设置,修改了各种可能有影响的超时设置等尝试解决问题,几经折腾后最终定位问题:使用的CDN服务超时设置不合理。

在域名开启CDN后,当时直接采用默认配置,没有过多关注细配置细节。实际上,有动态API接口(特别是文件上传接口)的域名启用CDN后应该确保API请求全部回源,且需要将回源时间调大一些:

  • 回源TCP链接时间;
  • 回源加载时间;

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK