Skip to content

Commit 072f25e

Browse files
committed
Revert IdleTimeoutHandler on HttpClient
Signed-off-by: raccoonback <[email protected]>
1 parent 3455d74 commit 072f25e

File tree

10 files changed

+59
-1354
lines changed

10 files changed

+59
-1354
lines changed

docs/modules/ROOT/pages/http-client.adoc

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -680,50 +680,6 @@ include::{examples-dir}/channeloptions/Application.java[lines=18..54]
680680
<4> Configures the time between individual `keepalive` probes to 1 minute.
681681
<5> Configures the maximum number of TCP `keepalive` probes to 8.
682682

683-
684-
==== IdleTimeout
685-
The maximum time (resolution: ms) that this connection stays opened and waits for HTTP request. Once the timeout is reached, the connection is closed.
686-
By default, `idleTimeout` is not specified, this indicates no timeout (i.e. infinite), which means the connection is closed only if one of the peers decides to close it explicitly.
687-
688-
NOTE: It is always a good practice to configure an idle timeout.
689-
690-
To customize the default settings, you can configure `HttpClient` as follows:
691-
692-
{examples-link}/idle/timeout/Application.java
693-
----
694-
include::{examples-dir}/idle/timeout/Application.java[lines=26..44]
695-
----
696-
<1> Configures the default idle timeout to 1 second.
697-
698-
===== Configuring Ping Frame for HTTP/2 Health Check
699-
When using the HTTP/2 protocol, it is recommended to configure a *PING* frame to maintain the connection and ensure timely health checks.
700-
The HttpClient in Reactor Netty allows setting up a *PING* frame to prevent idle connections from being prematurely closed when *idleTimeout* is configured.
701-
702-
[NOTE]
703-
====
704-
To enable HTTP/2 PING frame-based health checks, you must configure `idleTimeout`.
705-
Without `idleTimeout`, the connection may remain open indefinitely, preventing proper detection of inactive or unresponsive connections.
706-
Setting an appropriate `idleTimeout` ensures that PING-based health checks can effectively terminate unresponsive connections.
707-
====
708-
709-
*Benefits of Using PING Frames*
710-
711-
- Actively monitors connection health by checking real-time responses to *PING* frames.
712-
- Ensures that health checks detect unresponsive connections quickly.
713-
- Helps maintain long-lived connections in an efficient manner.
714-
715-
To enable *PING* frames for HTTP/2 connections, configure the HttpClient as follows:
716-
717-
{examples-link}/liveness/Application.java
718-
----
719-
include::{examples-dir}/liveness/Application.java[lines=26..49]
720-
----
721-
<1> To set up a health check using HTTP2 Ping frame, `idleTimeout` must be set first.
722-
<2> Sets the interval for sending `HTTP/2` `PING` frames and receiving `ACK` responses
723-
<3> Sets the execution interval for the scheduler that sends `HTTP/2` `PING frames and periodically checks for `ACK` responses
724-
<4> Sets the threshold for retrying `HTTP/2` `PING` frame transmissions.
725-
726-
727683
[[ssl-tls-timeout]]
728684
==== SSL/TLS Timeout
729685
`HttpClient` supports the SSL/TLS functionality provided by Netty.

reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/idle/timeout/Application.java

Lines changed: 0 additions & 44 deletions
This file was deleted.

reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/liveness/Application.java

Lines changed: 0 additions & 49 deletions
This file was deleted.

reactor-netty-http/src/main/java/reactor/netty/http/Http2SettingsSpec.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -456,32 +456,4 @@ public Builder pushEnabled(boolean pushEnabled) {
456456
}
457457
*/
458458
}
459-
460-
public Http2Settings http2Settings() {
461-
Http2Settings settings = Http2Settings.defaultSettings();
462-
463-
if (headerTableSize != null) {
464-
settings.headerTableSize(headerTableSize);
465-
}
466-
467-
if (initialWindowSize != null) {
468-
settings.initialWindowSize(initialWindowSize);
469-
}
470-
471-
if (maxConcurrentStreams != null) {
472-
settings.maxConcurrentStreams(maxConcurrentStreams);
473-
}
474-
475-
if (maxFrameSize != null) {
476-
settings.maxFrameSize(maxFrameSize);
477-
}
478-
479-
settings.maxHeaderListSize(maxHeaderListSize);
480-
481-
if (pushEnabled != null) {
482-
settings.pushEnabled(pushEnabled);
483-
}
484-
485-
return settings;
486-
}
487459
}

reactor-netty-http/src/main/java/reactor/netty/http/IdleTimeoutHandler.java

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import io.netty.channel.ChannelHandler;
1919
import io.netty.channel.ChannelHandlerContext;
2020
import io.netty.channel.ChannelPipeline;
21-
import io.netty.handler.codec.http.HttpClientCodec;
22-
import io.netty.handler.codec.http.HttpClientUpgradeHandler;
2321
import io.netty.handler.codec.http.HttpServerCodec;
2422
import io.netty.handler.codec.http.HttpServerUpgradeHandler;
2523
import io.netty.handler.timeout.IdleState;
@@ -123,45 +121,6 @@ public static void addIdleTimeoutServerHandler(ChannelPipeline pipeline, @Nullab
123121
}
124122
}
125123

126-
/**
127-
* Adds an idle timeout handler to the client pipeline.
128-
* This handler will close the connection if it remains idle for the specified duration.
129-
*
130-
* @param pipeline the channel pipeline to which the handler will be added
131-
* @param idleTimeout the duration of idle time after which the connection will be closed
132-
* @param httpConnectionLiveness the HTTP connection liveness checker to be used
133-
*/
134-
public static void addIdleTimeoutClientHandler(ChannelPipeline pipeline, @Nullable Duration idleTimeout,
135-
HttpConnectionLiveness httpConnectionLiveness) {
136-
if (idleTimeout != null && pipeline.get(NettyPipeline.IdleTimeoutHandler) == null) {
137-
String baseName = null;
138-
if (pipeline.get(NettyPipeline.HttpCodec) != null) {
139-
baseName = NettyPipeline.HttpCodec;
140-
}
141-
else {
142-
ChannelHandler httpClientUpgradeHandler = pipeline.get(HttpClientUpgradeHandler.class);
143-
if (httpClientUpgradeHandler != null) {
144-
baseName = pipeline.context(httpClientUpgradeHandler).name();
145-
}
146-
else {
147-
ChannelHandler httpClientCodec = pipeline.get(HttpClientCodec.class);
148-
if (httpClientCodec != null) {
149-
baseName = pipeline.context(httpClientCodec).name();
150-
}
151-
}
152-
}
153-
154-
pipeline.addAfter(
155-
baseName,
156-
NettyPipeline.IdleTimeoutHandler,
157-
new IdleTimeoutHandler(
158-
idleTimeout.toMillis(),
159-
httpConnectionLiveness
160-
)
161-
);
162-
}
163-
}
164-
165124
/**
166125
* Removes the idle timeout handler from the pipeline if it exists.
167126
*

reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClient.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,25 +1095,6 @@ public final HttpClient headersWhen(Function<? super HttpHeaders, Mono<? extends
10951095
return dup;
10961096
}
10971097

1098-
/**
1099-
* Specifies an idle timeout on the connection when it is waiting for an HTTP request (resolution: ms).
1100-
* Once the timeout is reached the connection will be closed.
1101-
* <p>If an {@code idleTimeout} is not specified, this indicates no timeout (i.e. infinite),
1102-
* which means the connection will be closed only if one of the peers decides to close it.
1103-
* <p>If the {@code idleTimeout} is less than {@code 1ms}, then {@code 1ms} will be the idle timeout.
1104-
* <p>By default {@code idleTimeout} is not specified.
1105-
*
1106-
* @param idleTimeout an idle timeout on the connection when it is waiting for an HTTP request (resolution: ms)
1107-
* @return a new {@link HttpClient}
1108-
* @since 1.2.5
1109-
*/
1110-
public final HttpClient idleTimeout(Duration idleTimeout) {
1111-
Objects.requireNonNull(idleTimeout, "idleTimeout");
1112-
HttpClient dup = duplicate();
1113-
dup.configuration().idleTimeout = idleTimeout;
1114-
return dup;
1115-
}
1116-
11171098
/**
11181099
* Apply HTTP/2 configuration.
11191100
*

0 commit comments

Comments
 (0)