-
Notifications
You must be signed in to change notification settings - Fork 667
Support a handler for checking connection status using Ping frame in HTTP/2 #3612
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
Open
raccoonback
wants to merge
21
commits into
reactor:1.2.x
Choose a base branch
from
raccoonback:issue-3301
base: 1.2.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
11f27c0
Support configuring the Ping frame interval in the HTTP/2 protocol
raccoonback 332bab0
Add a handler to check connection status via Ping frame health checks…
raccoonback 362a54b
Update doc related with HTTP/2
raccoonback 5fc0e8e
Ensure backward compatibility while adding support for configuring th…
raccoonback e795731
Fix unnecessary warnings in test code
raccoonback 54a186b
Http2ChannelDuplexHandler -> ChannelDuplexHandler
raccoonback 68cf596
Reduce the scope of access control
raccoonback 7e27e22
Fix broken test code
raccoonback fd2a918
Change comparison type for PING frame
raccoonback adb5fb5
Fix broken test
raccoonback 5de6219
Add configuration for HTTP/2 PING scheduler interval and retry threshold
raccoonback c3dc94b
Support HTTP health check in IdleTimeoutHandler via HTTP/2 PING
raccoonback 2efb7ff
Rollback previous Http2ConnectionLivenessHandler settings
raccoonback b49b5d6
Fix checkstyle
raccoonback 2368444
Rollback docs related with HTTP2 Ping
raccoonback ed8e74b
Fix broken test
raccoonback 34c7052
Update docs about HTTP2 Ping frame and IdleTimeout
raccoonback 9570a38
Add override annotation
raccoonback 666aa21
Disable checkstyle about channel close
raccoonback bcf82f4
Fix broken docs
raccoonback 8c75204
Stop scheduler when data is received, considering the connection active
raccoonback File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
.../main/java/reactor/netty/examples/documentation/http/client/idle/timeout/Application.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2025 VMware, Inc. or its affiliates, All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package reactor.netty.examples.documentation.http.client.idle.timeout; | ||
|
||
import io.netty.handler.codec.http.HttpHeaders; | ||
import reactor.core.publisher.Mono; | ||
import reactor.netty.http.HttpProtocol; | ||
import reactor.netty.http.client.HttpClient; | ||
import reactor.util.function.Tuple2; | ||
|
||
import java.time.Duration; | ||
|
||
public class Application { | ||
|
||
public static void main(String[] args) { | ||
HttpClient client = | ||
HttpClient.create() | ||
.protocol(HttpProtocol.H2) | ||
.secure() | ||
.idleTimeout(Duration.ofSeconds(1)); //<1> | ||
|
||
Tuple2<String, HttpHeaders> response = | ||
client.get() | ||
.uri("https://example.com/") | ||
.responseSingle((res, bytes) -> bytes.asString() | ||
.zipWith(Mono.just(res.responseHeaders()))) | ||
.block(); | ||
System.out.println("Used stream ID: " + response.getT2().get("x-http2-stream-id")); | ||
System.out.println("Response: " + response.getT1()); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
.../src/main/java/reactor/netty/examples/documentation/http/client/liveness/Application.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) 2025 VMware, Inc. or its affiliates, All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package reactor.netty.examples.documentation.http.client.liveness; | ||
|
||
import io.netty.handler.codec.http.HttpHeaders; | ||
import reactor.core.publisher.Mono; | ||
import reactor.netty.http.HttpProtocol; | ||
import reactor.netty.http.client.HttpClient; | ||
import reactor.util.function.Tuple2; | ||
|
||
import java.time.Duration; | ||
|
||
public class Application { | ||
|
||
public static void main(String[] args) { | ||
HttpClient client = | ||
HttpClient.create() | ||
.protocol(HttpProtocol.H2) | ||
.secure() | ||
.idleTimeout(Duration.ofSeconds(1)) //<1> | ||
.http2Settings( | ||
builder -> builder.pingAckTimeout(Duration.ofMillis(600)) // <2> | ||
.pingScheduleInterval(Duration.ofMillis(300)) // <3> | ||
.pingAckDropThreshold(2) // <4> | ||
); | ||
|
||
Tuple2<String, HttpHeaders> response = | ||
client.get() | ||
.uri("https://example.com/") | ||
.responseSingle((res, bytes) -> bytes.asString() | ||
.zipWith(Mono.just(res.responseHeaders()))) | ||
.block(); | ||
System.out.println("Used stream ID: " + response.getT2().get("x-http2-stream-id")); | ||
System.out.println("Response: " + response.getT1()); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
.../src/main/java/reactor/netty/examples/documentation/http/server/liveness/Application.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2025 VMware, Inc. or its affiliates, All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package reactor.netty.examples.documentation.http.server.liveness; | ||
|
||
import reactor.netty.DisposableServer; | ||
import reactor.netty.http.Http2SslContextSpec; | ||
import reactor.netty.http.HttpProtocol; | ||
import reactor.netty.http.server.HttpServer; | ||
|
||
import java.io.File; | ||
import java.time.Duration; | ||
|
||
public class Application { | ||
|
||
public static void main(String[] args) { | ||
File cert = new File("certificate.crt"); | ||
File key = new File("private.key"); | ||
|
||
Http2SslContextSpec http2SslContextSpec = Http2SslContextSpec.forServer(cert, key); | ||
|
||
DisposableServer server = | ||
HttpServer.create() | ||
.port(8080) | ||
.protocol(HttpProtocol.H2) | ||
.secure(spec -> spec.sslContext(http2SslContextSpec)) | ||
.idleTimeout(Duration.ofSeconds(1)) //<1> | ||
.http2Settings( | ||
builder -> builder.pingAckTimeout(Duration.ofMillis(600)) // <2> | ||
.pingScheduleInterval(Duration.ofMillis(300)) // <3> | ||
.pingAckDropThreshold(2) // <4> | ||
) | ||
.bindNow(); | ||
|
||
server.onDispose() | ||
.block(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you please elaborate more on this?
This is HttpClient so it initiates the HTTP request. (May be you mean the connection stays idle in the connection pool?) As part of the connection pool we already have a configuration for dropping the idle connections so this new configuration seems to be not needed? (check Http2Pool)
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.
@violetagg
This describes configuring
IdleTimeout
on the HttpClient side usingIdleTimeoutHandler
, independently of the connection pool settings.From my understanding, since the connection pool already manages idle connections, applying an additional
IdleTimeoutHandler
at theHttpClient
level may be redundant.Could you please confirm if this understanding is accurate?
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.
yes I think it is redundant