Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable auto ack for HTTP/2 PING frames by netty #1558

Merged
merged 1 commit into from
May 13, 2021

Conversation

idelpivnitskiy
Copy link
Member

Motivation:

KeepAliveManager#pingReceived always acks PING frames. Netty's auto
ack produces additional PING-ack frames that are not necessary and
confusing.

Modifications:

  • Use Http2FrameCodecBuilder#autoAckPingFrame(false) on client and
    server sides;

Result:

No duplicated PING frames written with ack=true.

Motivation:

`KeepAliveManager#pingReceived` always acks PING frames. Netty's auto
ack produces additional PING-ack frames that are not necessary and
confusing.

Modifications:

- Use `Http2FrameCodecBuilder#autoAckPingFrame(false)` on client and
server sides;

Result:

No duplicated PING frames written with ack=true.
@@ -48,6 +48,8 @@ public void init(final Channel channel) {
// The max concurrent streams is made available via a publisher and may be consumed asynchronously
// (e.g. when offloading is enabled), so we manually control the SETTINGS ACK frames.
.autoAckSettingsFrame(false)
// We ack PING frames in KeepAliveManager#pingReceived.
.autoAckPingFrame(false)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All PING frames are handled here and always ack'ed:

void pingReceived(final Http2PingFrame pingFrame) {
assert channel.eventLoop().inEventLoop();
if (pingFrame.ack()) {
long pingAckContent = pingFrame.content();
if (pingAckContent == GRACEFUL_CLOSE_PING_CONTENT) {
LOGGER.debug("channel={}, graceful close ping ack received.", channel);
cancelIfStateIsAFuture(gracefulCloseState);
gracefulCloseWriteSecondGoAway();
} else if (pingAckContent == KEEP_ALIVE_PING_CONTENT) {
cancelIfStateIsAFuture(keepAliveState);
keepAliveState = null;
}
} else {
// Send an ack for the received ping
channel.writeAndFlush(new DefaultHttp2PingFrame(pingFrame.content(), true));
}
}

@idelpivnitskiy idelpivnitskiy merged commit 4e128eb into apple:main May 13, 2021
@idelpivnitskiy idelpivnitskiy deleted the autoAckPingFrame branch May 13, 2021 00:53
hbelmiro pushed a commit to hbelmiro/servicetalk that referenced this pull request May 23, 2021
Motivation:

`KeepAliveManager#pingReceived` always acks PING frames. Netty's auto
ack produces additional PING-ack frames that are not necessary and
confusing.

Modifications:

- Use `Http2FrameCodecBuilder#autoAckPingFrame(false)` on client and
server sides;

Result:

No duplicated PING frames written with ack=true.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants