Skip to content
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

Add HttpServer TLS Timeout Configuration section to reference documentation #2832

Merged
merged 1 commit into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/asciidoc/http-server.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -678,3 +678,36 @@ include::{examplesdir}/uds/Application.java[lines=18..33]
----
<1> Specifies `DomainSocketAddress` that will be used
====

== Timeout Configuration
This section describes various timeout configuration options that can be used in `HttpServer`.
Configuring a proper timeout may improve or solve issues in the communication process.
The configuration options can be grouped as follows:

* <<http-server-ssl-tls-timeout>>

[[http-server-ssl-tls-timeout]]
=== SSL/TLS Timeout
`HttpServer` supports the SSL/TLS functionality provided by Netty.

The following list describes the available timeout configuration options:

* `handshakeTimeout` - Use this option to configure the SSL handshake timeout (resolution: ms). Default: 10s.

NOTE: You should consider increasing the SSL handshake timeout when expecting slow network connections.

* `closeNotifyFlushTimeout` - Use this option to configure the SSL `close_notify` flush timeout (resolution: ms). Default: 3s.
* `closeNotifyReadTimeout` - Use this option to configure the SSL `close_notify` read timeout (resolution: ms). Default: 0s.

To customize the default settings, you can configure `HttpServer` as follows:

====
[source,java,indent=0]
.{examplesdir}/security/custom/Application.java
----
include::{examplesdir}/security/custom/Application.java[lines=18..44]
----
<1> Configures the SSL handshake timeout to 30 seconds.
<2> Configures the SSL `close_notify` flush timeout to 10 seconds.
<3> Configures the SSL `close_notify` read timeout to 10 seconds.
====
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2023 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.security.custom;

import reactor.netty.DisposableServer;
import reactor.netty.http.Http11SslContextSpec;
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");

Http11SslContextSpec http11SslContextSpec = Http11SslContextSpec.forServer(cert, key);

DisposableServer server =
HttpServer.create()
.secure(spec -> spec.sslContext(http11SslContextSpec)
.handshakeTimeout(Duration.ofSeconds(30)) //<1>
.closeNotifyFlushTimeout(Duration.ofSeconds(10)) //<2>
.closeNotifyReadTimeout(Duration.ofSeconds(10))) //<3>
.bindNow();

server.onDispose()
.block();
}
}