Repository navigation
Http2 keepalive - #5144
Http2 keepalive#5144
Conversation
…fix to make it work." This reverts commit 02ab78d.
…r connections by sending PING frames if the conection is idle longer than the threshold.
|
Any ideas how get the additional test coverage. Just adding |
mhils
left a comment
There was a problem hiding this comment.
This looks fantastic, thanks! 🍰
I don't have time for a proper review in the next few days, but a few high-level points:
- The
RequestKeepAlive/KeepAlivecommand/event pair is too specific. Let's aim for a generic timer functionality that can be reused in other protocols. For example, name itScheduleWakeup/WakeuporSetTimer/TimerExpired. The wakup event would then always be executed after the specified amount of seconds. In the HTTP/2 layer, we keep a timestamp of the last activity. If we are woken up whilelast_activity + http2_ping_threshold > time.time()(because something happened in the meantime), we just reschedule a new timer with the remaining time. - I think we should enable this by default with the same 58s setting as Firefox. There's no harm, is there?
The idle watchdog would go away with the changes proposed in my previous comment. Let's focus on the test coverage of the HTTP/2 bits. :) |
|
I finally found some time to reorganize this in the way you requested. Only one missing piece: I looked for |
My proposal was to do this, we aren't doing it yet. Sorry, that was a bit unclear. 😅 |
f0383ea to
7352811
Compare
|
OK, next try. I have restructured this as discussed, |
mhils
left a comment
There was a problem hiding this comment.
This looks awesome, thanks! 😃🍰
I've added a few comments below, let me know if anything is unclear. :)
| << OpenConnection(server) | ||
| >> reply(None, side_effect=make_h2) | ||
| << RequestWakeup(1) | ||
| << SendData(server, initial) |
There was a problem hiding this comment.
We should emulate a Wakeup event here and make sure that it triggers a PING. :-)
def test_request_keepalive(monkeypatch, tctx):
...
assert (playbook ...)
t = time.time()
monkeypatch.setattr(time, "time", lambda: t + 60)
assert (playbook >> Wakeup() ...)There was a problem hiding this comment.
I'll do this at the very end, when the rest is working. :)
Co-authored-by: Maximilian Hils <[email protected]>
Co-authored-by: Maximilian Hils <[email protected]>
Co-authored-by: Maximilian Hils <[email protected]>
Co-authored-by: Maximilian Hils <[email protected]>
Co-authored-by: Maximilian Hils <[email protected]>
|
The update should implement the proper routing of the |
mhils
left a comment
There was a problem hiding this comment.
Looks awesome now! 💯
I only have some comments that should be very easy to implement.
Quite some tests for HTTP/2 are broken due to the additional WakeupRequest command and I am not sure whether I should just disable PING for all test cases except for the ones explicitly testing the functionality. Or fix all broken tests.
I think just disabling it for those tests is totally fine. 👍 I'm happy with either approach though, whatever you find is easier. 😃
Co-authored-by: Maximilian Hils <[email protected]>
Co-authored-by: Maximilian Hils <[email protected]>
Co-authored-by: Maximilian Hils <[email protected]>
Fixed almost all tests
|
OK, next update. I had to add
|
No, that's fine. :)
Do you want to push what you have/what is not working so far? I'm busy with family stuff over easter, but happy to look at this (and your other questions) next week. :) |
|
No need to hurry. :) My sample test is already in the commit, the last one in test_http2.py. All other tests are fixed. |
This allows us to use it with `reply()` in tests, which makes sure that the correct instance is reused. # Please enter the commit message for your changes. Lines starting
mhils
left a comment
There was a problem hiding this comment.
This looks good to merge now, thank you very much again! 🍰 🚀 😃
Description
This is a first PR for the implementation of the HTTP/2 keep-alive via ping as discussed in #5044 and the subsequent open issue #5046.
I am open about naming of options, classes and functions, just tell me what you would like. The RequestKeepAlive command can be extended with a version int to deal with future HTTP versions that require a similar strategy but other intervals and messages.
Questions that I am not sure:
Checklist