-
Notifications
You must be signed in to change notification settings - Fork 934
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
Send an HTTP/2 PING frame on an idle connection #2409
Conversation
core/src/main/java/com/linecorp/armeria/server/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
That was fast! Let me take a look soon. 🙇♂️ |
Codecov Report
@@ Coverage Diff @@
## master #2409 +/- ##
============================================
- Coverage 73.63% 73.59% -0.05%
- Complexity 10865 10906 +41
============================================
Files 952 953 +1
Lines 41581 41795 +214
Branches 5219 5240 +21
============================================
+ Hits 30620 30757 +137
- Misses 8288 8341 +53
- Partials 2673 2697 +24
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work all in all! Are you going to implement this on the client-side as well?
core/src/main/java/com/linecorp/armeria/server/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/server/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/server/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/server/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/server/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/server/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/server/Http2ServerConnectionHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/server/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
Yes Trustin, I will implement for client side as well. Also, will make all the suggested corrections. Thanks for your quick review 🙇 |
core/src/main/java/com/linecorp/armeria/internal/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/AbstractHttp2ConnectionHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/IdleTimeoutHandler.java
Outdated
Show resolved
Hide resolved
@trustin Can you please skim through when you get some spare time. I have used AbstractHttp2ConnectionHandler.handlerAdded() to change state of IdleTimeoutHandler from http1 to http2. If this looks, I will proceed further. 🙇 |
core/src/main/java/com/linecorp/armeria/internal/AbstractHttp2ConnectionHandler.java
Outdated
Show resolved
Hide resolved
I hope this is ready for full review now. Changing to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, @sivaalli! Left some nits only. 👍
core/src/main/java/com/linecorp/armeria/client/HttpClientPipelineConfigurator.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/linecorp/armeria/internal/Http2KeepAliveHandlerTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/linecorp/armeria/internal/Http2KeepAliveHandlerTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/linecorp/armeria/internal/Http2KeepAliveHandlerTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/linecorp/armeria/internal/Http2KeepAliveHandlerTest.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/Http2ClientConnectionHandler.java
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/HttpClientPipelineConfigurator.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/IdleTimeoutHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/Http2ClientConnectionHandler.java
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
b5c5786
to
878d7b9
Compare
@sivaalli How's this PR going? Anything we can help? |
@trustin I've resumed working on this. As discussed, I will make changes
And let user decide whats best for their use case. The implementation mostly looks like the one in grpc. I will push code for review when I have working code. Thanks for your patience :) |
6e501ae
to
d3a320a
Compare
The tests are incomplete, but feel free to skim if possible. Will work on tests and then will formally request a full review. :) |
…ineConfigurator.java Co-Authored-By: Anuraag Agrawal <[email protected]>
b13946c
to
6836434
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! @sivaalli. Thanks!
core/src/main/java/com/linecorp/armeria/internal/common/Http2KeepAliveHandler.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work! Great thanks to @sivaalli 🙇♂️
core/src/main/java/com/linecorp/armeria/client/ClientFactoryBuilder.java
Outdated
Show resolved
Hide resolved
I really appreciate your hard work on this, @sivaalli ❤️ |
Related: line#2388 line#1263 Motivation: It is possible that an HTTP/2 connection has no traffic at all even if there are active streams. In such a case, Armeria client or server could send some PING frames to keep the connection alive or to detect TCP-level failure quickly. Modifications: - Add `http2PingTimeoutMillis` and `useHttp2PingWhenNoActiveStreams` option Result: - Fixes line#1263 Co-authored-by: Trustin Lee <[email protected]> Co-authored-by: Anuraag Agrawal <[email protected]>
Related: #2388 #1263
Motivation:
It is possible that an HTTP/2 connection has no traffic at all even if there are active streams. In such a case, Armeria client or server could send some PING frames to keep the connection alive or to detect TCP-level failure quickly.
Modifications:
http2PingTimeoutMillis
anduseHttp2PingWhenNoActiveStreams
optionResult:
@trustin @anuraaga Please let me know what do you think of this.
Previous conversation: #2388
Issue: #1263
Since we thought of sending PING when idle (regardless of if there are open streams or not) , I leveraged
IdlePingHandler
.~~This is not complete yet, but wanted to get overall feedback on the approach. ~~
The continuation for this would be is to addIdleStateHandler
which emitsIdleStateEvent
for http2 channels and useHttpServerIdleTimeoutHandler
for http1.1 channels.pingTimeoutInMillis
Http2KeepAliveHandler