http/2 chrome 无法service push问题

发布于 2022-09-11 23:12:02 字数 6162 浏览 23 评论 0

Hey there,

我在Mac os-x 使用nginx自建证书,支持https/http2,使用nginx指令

http2_push_preload on;

http2_push /style.css;

推送给客户端style,但是在network面板里面看不到push的结果。通过netlog-views 查看请求发现:


33367 \[st=0\]  HTTP2\_SESSION\_RECV\_PUSH\_PROMISE
                --> :method: GET
                    :path: /style.css
                    :scheme: https
                    :authority: www.e.com
                    accept-encoding: gzip, deflate, br
                    accept-language: zh,en;q=0.9,zh-CN;q=0.8,zh-TW;q=0.7,da;q=0.6
                    user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10\_15\_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36
                --> id = 3
                --> promised\_stream\_id = 4
t=33367 \[st=0\]  HTTP2\_SESSION\_SEND\_RST\_STREAM
                --> description = "Duplicate pushed stream with url: https://www.e.com/style.css"
                --> error\_code = "7 (REFUSED\_STREAM)"
                --> stream\_id = 4
t=33367 \[st=0\]  HTTP2\_SESSION\_RECV\_HEADERS
                --> fin = false
                --> :status: 200
                    server: nginx/1.17.1
                    date: Mon, 28 Oct 2019 12:53:50 GMT
                    content-type: text/html
                    content-length: 614
                    last-modified: Mon, 28 Oct 2019 12:18:43 GMT
                    etag: "5db6dca3-266"
                    accept-ranges: bytes
                --> stream\_id = 3
                
                

这里奇怪的提示:

Duplicate pushed stream with

有两个疑问:

  1. 为什么Duplicate了呢?
  2. 为什么这帧的流id是4,但是请求的流id是3。

求解释~~

完整的log如下:


482506: HTTP2_SESSION
Start Time: 2019-10-28 20:53:50.036

t=33367 [st=0]  HTTP2_SESSION_PING
                --> is_ack = false
                --> type = "sent"
                --> unique_id = 1
t=33367 [st=0]  HTTP2_SESSION_SEND_HEADERS
                --> exclusive = true
                --> fin = true
                --> has_priority = true
                --> :method: GET
                    :authority: www.e.com
                    :scheme: https
                    :path: /
                    cache-control: max-age=0
                    upgrade-insecure-requests: 1
                    user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36
                    sec-fetch-mode: navigate
                    sec-fetch-user: ?1
                    accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
                    sec-fetch-site: none
                    accept-encoding: gzip, deflate, br
                    accept-language: zh,en;q=0.9,zh-CN;q=0.8,zh-TW;q=0.7,da;q=0.6
                --> parent_stream_id = 0
                --> source_dependency = 483310 (HTTP_STREAM_JOB)
                --> stream_id = 3
                --> weight = 256
t=33367 [st=0]  HTTP2_SESSION_RECV_PUSH_PROMISE
                --> :method: GET
                    :path: /style.css
                    :scheme: https
                    :authority: www.e.com
                    accept-encoding: gzip, deflate, br
                    accept-language: zh,en;q=0.9,zh-CN;q=0.8,zh-TW;q=0.7,da;q=0.6
                    user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36
                --> id = 3
                --> promised_stream_id = 4
t=33367 [st=0]  HTTP2_SESSION_SEND_RST_STREAM
                --> description = "Duplicate pushed stream with url: https://www.e.com/style.css"
                --> error_code = "7 (REFUSED_STREAM)"
                --> stream_id = 4
t=33367 [st=0]  HTTP2_SESSION_RECV_HEADERS
                --> fin = false
                --> :status: 200
                    server: nginx/1.17.1
                    date: Mon, 28 Oct 2019 12:53:50 GMT
                    content-type: text/html
                    content-length: 614
                    last-modified: Mon, 28 Oct 2019 12:18:43 GMT
                    etag: "5db6dca3-266"
                    accept-ranges: bytes
                --> stream_id = 3
t=33368 [st=1]  HTTP2_SESSION_RECV_DATA
                --> fin = false
                --> size = 614
                --> stream_id = 3
t=33368 [st=1]  HTTP2_SESSION_UPDATE_RECV_WINDOW
                --> delta = -614
                --> window_size = 15728008
t=33368 [st=1]  HTTP2_SESSION_RECV_DATA
                --> fin = true
                --> size = 0
                --> stream_id = 3
t=33368 [st=1]  HTTP2_SESSION_PING
                --> is_ack = true
                --> type = "received"
                --> unique_id = 1
t=33368 [st=1]  HTTP2_SESSION_RECV_HEADERS
                --> fin = false
                --> :status: 200
                    server: nginx/1.17.1
                    date: Mon, 28 Oct 2019 12:53:50 GMT
                    content-type: text/css
                    content-length: 18
                    last-modified: Mon, 28 Oct 2019 12:18:01 GMT
                    etag: "5db6dc79-12"
                    accept-ranges: bytes
                --> stream_id = 4
t=33368 [st=1]  HTTP2_SESSION_RECV_DATA
                --> fin = false
                --> size = 18
                --> stream_id = 4
t=33368 [st=1]  HTTP2_SESSION_UPDATE_RECV_WINDOW
                --> delta = -18
                --> window_size = 15727990
t=33368 [st=1]  HTTP2_SESSION_UPDATE_RECV_WINDOW
                --> delta = 18
                --> window_size = 15728008
t=33368 [st=1]  HTTP2_SESSION_RECV_DATA
                --> fin = true
                --> size = 0
                --> stream_id = 4
t=33368 [st=1]  HTTP2_SESSION_UPDATE_RECV_WINDOW
                --> delta = 614
                --> window_size = 15728622

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文