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

HTTP2 with HTTP1 : HTTP1 is always used #484

Closed
vincent-wuhrlin opened this issue Oct 27, 2018 · 2 comments
Closed

HTTP2 with HTTP1 : HTTP1 is always used #484

vincent-wuhrlin opened this issue Oct 27, 2018 · 2 comments
Labels
type/bug A general bug
Milestone

Comments

@vincent-wuhrlin
Copy link

Expected behavior

I have configured Netty Reactor with Spring Boot and HTTP2. All is working fine, thanks for these awesome frameworks. However, it's impossible to use HTTP2 with HTTP1 (TLS), because in this case, only HTTP1 is always used and prior to HTTP2.

It is possible to use HTTP2 and HTTP1 together, and fallback to HTTP1 only if client doesn't support it ?

Thanks you for your help.

Actual behavior

HTTP 2

I have configured ReactiveWebServerFactory, and when i enabled only HTTP2, all is working fine, logs (curl / server) are below :
http2 only - server.log
http2 only - client.log

HTTP 2 + HTTP 1

My objective is to fallback to HTTP1 if browser doesn't support HTTP2.
I have configured ReactiveWebServerFactory, and added HTTP1 in protocols list.
All is working fine, but HTTP1 is always used, and HTTP2 never enabled, even with curl flag --http2. Logs (curl / server) are below :
http1.1 + http2 - client.log
http1.1 + http2 - server.log

Steps to reproduce

Simply create an HTTP Server with Spring boot and customize ReactiveWebServerFactory :

NettyReactiveWebServerFactory factory = new NettyReactiveWebServerFactory();
...
factory.addServerCustomizers(httpServer ->
{
    return httpServer.protocol(HttpProtocol.HTTP11, HttpProtocol.H2);
});

Reactor Netty version

0.8.1.RELEASE

JVM version (e.g. java -version)

java version "10.0.2" 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)

OS version (e.g. uname -a)

Darwin MBP-de-Vincent 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64

@smaldini smaldini added this to the 0.8.2.RELEASE milestone Oct 27, 2018
@smaldini smaldini added the type/bug A general bug label Oct 27, 2018
@smaldini
Copy link
Contributor

Good catch we didnt use application protocol selection in that case, should be fixed in the release today.

smaldini pushed a commit that referenced this issue Oct 27, 2018
@smaldini
Copy link
Contributor

smaldini commented Oct 27, 2018

Also for H2 vs H2C make sure you configure SSL somewhere :

SelfSignedCertificate cert = new SelfSignedCertificate();
		SslContextBuilder serverOptions = SslContextBuilder.forServer(cert.certificate(), cert.privateKey());

DisposableServer server =
				HttpServer.create()
				          .protocol(HttpProtocol.H2, HttpProtocol.HTTP11)
				          .secure(ssl -> ssl.sslContext(serverOptions))
				          .port(8080)
				          .handle((req, res) -> res.sendString(Mono.just("Hello")))
				          .wiretap(true)
				          .bindNow();

new CountDownLatch(1).await();
server.disposeNow();

smaldini pushed a commit that referenced this issue Oct 28, 2018
This amends the fix previously applied for 484.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants