Add HTTP/2 keep-alive PING policy.#606
Conversation
|
@arturobernalg The change-set will likely need some work, but I am conceptually fine with it. @rschmitt Would you have any conceptual objections to the idea? |
0d9a332 to
a80a98d
Compare
Emit PINGs on otherwise idle connections once SETTINGS are ACKed, and close the session if the peer does not ACK within the configured timeout.
a80a98d to
6224ba5
Compare
This sounds way better than the current HTTP/2 implementation of |
|
I think we have too many config knobs already. I'd really prefer to expose this through |
|
keep-alive is now driven via setValidateAfterInactivity (no new H2Config knob), so it fits the existing connection validation API. |
@ok2c should i do another change here? |
|
@arturobernalg I like the fact that API changes are small, but I find the implementation too complex and overwrought: The process should be quite simple:
|
Initialize keep-alive before first session
@ok2c I reworked the keep-alive handling to follow the exact 4-step process you outlined |
| } | ||
|
|
||
| if (connState.compareTo(ConnectionHandshake.ACTIVE) <= 0 && remoteSettingState == SettingsHandshake.ACKED) { | ||
| while (streams.getLocalCount() < remoteConfig.getMaxConcurrentStreams()) { |
There was a problem hiding this comment.
@arturobernalg It has to be massively simpler
In AbstractH2StreamMultiplexer at the line 522 do the following
if (hasBeenIdleTooLong && ioSession.hasCommands() && pingHandlers.isEmpty()) {
ioSession.setSocketTimeout(Timeout.ofSeconds(5));
executePing(new PingCommand(new BasicPingHandler(new Callback<Boolean>() {
@Override
public void execute(final Boolean result) {
// restore timeout
ioSession.setSocketTimeout(...);
if (result) {
// proceed with command execution
requestSessionOutput();
} else {
ioSession.enqueue(new ShutdownCommand(CloseMode.GRACEFUL), Command.Priority.NORMAL);
}
}
})));
return;
}
Add idle time tracking, and that should be all it takes.
There was a problem hiding this comment.
@ok2c
I reworked it to the massively simpler pre-flight PING: only when idle > validateAfterInactivity and commands are pending, with a short ACK timeout and restoring the previous socket timeout.
Issue a single PING before executing pending commands when the session has been idle longer than validateAfterInactivity. Use a short ACK timeout and restore the previous socket timeout on completion. This is a stale-check, not a periodic keep-alive mechanism.
Issue a single pre-flight HTTP/2 PING before executing pending commands when idle > validateAfterInactivity.
Use a short ACK timeout and restore the previous socket timeout on completion.