Skip to content

HTTP/2: one PING is answered with two ACKs #222

Closed

Description

@EdmondDantes

What the code does

cb_on_frame_recv submits the PING ACK itself (src/http2/http2_session.c:722):

if (frame->hd.type == NGHTTP2_PING) {
    ...
    } else {
        (void)nghttp2_submit_ping(ng, NGHTTP2_FLAG_ACK, frame->ping.opaque_data);
    }
}

The comment above it explains why: nghttp2's automatic ACK in
nghttp2_session_on_ping_received is withheld from a closing session, which is
the state a gRPC shutdown sequence reaches, and the peer then waits out its own
timeout (nghttp2 #1103).

What the comment does not say is that nghttp2's automatic ACK is still on, so on
every other connection both fire.

Measurement

One PING sent, ACKs counted off the wire on 52dbeb6:

session PING ACKs
live, one request in flight 2
peer sent GOAWAY, no stream open 2

The frame sequence for the live case is SETTINGS, SETTINGS ACK, PING ACK, PING ACK, WINDOW_UPDATE, HEADERS, DATA.

A client measuring round-trip time from its PING retires the exchange on the
first ACK and sees the second as an ACK for a PING it never sent.

Fix

nghttp2_option_set_no_auto_ping_ack(opt, 1) in apply_hardened_options, beside
the no_auto_window_update the session already sets, so the ACK the peer gets is
the one the server submits — in both states.

Activity

  1. added this to the Next3 milestone on Aug 22, 2026
  2. self-assigned this
    on Aug 22, 2026
  3. added
    bug
    on Aug 22, 2026
  4. EdmondDantes commented on Aug 23, 2026

    @EdmondDantes
    ContributorAuthor

    Fixed in bf7e86b: apply_hardened_options sets nghttp2_option_set_no_auto_ping_ack(opt, 1) (src/http2/http2_session.c:1237), so the only ACK on the wire is the one cb_on_frame_recv submits. Evidence: tests/phpt/server/h2/058-h2-ping-ack-once.phpt counts the ACKs off the wire on a live session and on one the peer has GOAWAYed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions