Skip to content

Commit 16b53e8

Browse files
committed
Merge branch 'release/1.3.0'
2 parents f726d7a + 9054288 commit 16b53e8

File tree

55 files changed

+2910
-948
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2910
-948
lines changed

.github/workflows/ci-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
os: [ ubuntu-20.04, macos-11, windows-2019 ]
18+
os: [ ubuntu-20.04, macos-12, windows-2019 ]
1919
jdk: [ 8, 11, 17, 21 ]
2020
fail-fast: false
2121

README.md

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,30 @@
22
[![Build](https://github.com/jauntsdn/netty-websocket-http2/actions/workflows/ci-build.yml/badge.svg)](https://github.com/jauntsdn/netty-websocket-http2/actions/workflows/ci-build.yml)
33
# netty-websocket-http2
44

5-
Netty based implementation of [rfc8441](https://tools.ietf.org/html/rfc8441) - bootstrapping websockets with http/2
5+
Netty based implementation of [rfc8441](https://tools.ietf.org/html/rfc8441) - bootstrapping websockets with http/2, and multiprotocol support (websocket-over-http1, websocket-over-http2).
66

7-
Library addresses 2 use cases: for application servers and clients,
8-
It is transparent use of existing http1 websocket handlers on top of http2 streams; for gateways/proxies,
9-
It is websockets-over-http2 support with no http1 dependencies and minimal overhead.
7+
### use cases
8+
9+
* Websocket channel API
10+
11+
for application servers and clients, It provides transparent use of existing http1 websocket handlers on top of http2 streams. Compatible with
12+
callbacks codec (described below).
13+
14+
* Websocket handshake only API
15+
16+
for gateways/proxies, It provides websockets-over-http2 support with no http1 dependencies and minimal overhead.
17+
18+
* Websocket multiprotocol
19+
20+
for application servers, It provides transparent use of existing http1 websocket handlers to process both http1 and http2 websockets.
21+
Compatible with callbacks codec (described below).
1022

1123
[https://jauntsdn.com/post/netty-websocket-http2/](https://jauntsdn.com/post/netty-websocket-http2/)
1224

1325
### much faster http1 codec
14-
Integration with [jauntsdn/netty-websocket-http1](https://github.com/jauntsdn/netty-websocket-http2/tree/develop/netty-websocket-http2-callbacks-codec) codec for websocket-http1
26+
Integration with [jauntsdn/netty-websocket-http1](https://github.com/jauntsdn/netty-websocket-http2/tree/develop/netty-websocket-http2-callbacks-codec) codec (callbacks codec) for websocket-http1
1527
frames processing [improves](https://github.com/jauntsdn/netty-websocket-http2/tree/develop/netty-websocket-http2-perftest/src/main/java/com/jauntsdn/netty/handler/codec/http2/websocketx/perftest/callbackscodec)
16-
throughput 1.4x - 1.7x for small messages.
28+
throughput 1.4x - 1.7x for small messages compared to one provided by netty (default codec).
1729

1830
### websocket channel API
1931
Intended for application servers and clients.
@@ -25,6 +37,7 @@ EchoWebSocketHandler http1WebSocketHandler = new EchoWebSocketHandler();
2537
2638
Http2WebSocketServerHandler http2webSocketHandler =
2739
Http2WebSocketServerBuilder.create()
40+
.codec(Http1WebSocketCodec.DEFAULT)
2841
.acceptor(
2942
(ctx, path, subprotocols, request, response) -> {
3043
switch (path) {
@@ -70,6 +83,7 @@ EchoWebSocketHandler http1WebSocketHandler = new EchoWebSocketHandler();
7083
7184
Http2WebSocketClientHandler http2WebSocketClientHandler =
7285
Http2WebSocketClientBuilder.create()
86+
.codec(Http1WebSocketCodec.DEFAULT)
7387
.handshakeTimeoutMillis(15_000)
7488
.build();
7589
@@ -87,7 +101,7 @@ EchoWebSocketHandler http1WebSocketHandler = new EchoWebSocketHandler();
87101
Http2WebSocketClientHandshaker handShaker = Http2WebSocketClientHandshaker.create(channel);
88102
89103
Http2Headers headers =
90-
new DefaultHttp2Headers().set("user-agent", "jauntsdn-websocket-http2-client/1.2.5");
104+
new DefaultHttp2Headers().set("user-agent", "jauntsdn-websocket-http2-client/1.2.6");
91105
ChannelFuture handshakeFuture =
92106
/*http1 websocket handler*/
93107
handShaker.handshake("/echo", headers, new EchoWebSocketHandler());
@@ -127,6 +141,26 @@ Runnable demo is available in `netty-websocket-http2-example` module -
127141
[handshakeserver](https://github.com/jauntsdn/netty-websocket-http2/blob/develop/netty-websocket-http2-example/src/main/java/com/jauntsdn/netty/handler/codec/http2/websocketx/example/handshakeserver/Main.java),
128142
[channelclient](https://github.com/jauntsdn/netty-websocket-http2/blob/develop/netty-websocket-http2-example/src/main/java/com/jauntsdn/netty/handler/codec/http2/websocketx/example/channelclient/Main.java).
129143

144+
### websocket multiprotocol
145+
Provides transparent use of existing http1 websocket handlers to process both http1 and http2 websockets.
146+
147+
* Server
148+
```groovy
149+
MultiProtocolWebSocketServerHandler multiprotocolHandler =
150+
MultiprotocolWebSocketServerBuilder.create()
151+
.path("/echo")
152+
.subprotocols("echo.jauntsdn.com")
153+
.defaultCodec()
154+
.handler(new DefaultEchoWebSocketHandler())
155+
.build();
156+
ch.pipeline().addLast(sslHandler, multiprotocolHandler);
157+
```
158+
159+
Runnable demo is available in `netty-websocket-http2-example` module -
160+
[multiprotocol.server.defaultcodec](https://github.com/jauntsdn/netty-websocket-http2/blob/develop/netty-websocket-http2-example/src/main/java/com/jauntsdn/netty/handler/codec/http2/websocketx/example/multiprotocol/server/defaultcodec/Main.java),
161+
[multiprotocol.server.callbackscodec](https://github.com/jauntsdn/netty-websocket-http2/blob/develop/netty-websocket-http2-example/src/main/java/com/jauntsdn/netty/handler/codec/http2/websocketx/example/multiprotocol/server/callbackscodec/Main.java),
162+
[multiprotocol.client.defaultcodec](https://github.com/jauntsdn/netty-websocket-http2/blob/develop/netty-websocket-http2-example/src/main/java/com/jauntsdn/netty/handler/codec/http2/websocketx/example/multiprotocol/client/Main.java),
163+
130164
### configuration
131165
Initial settings of server http2 codecs (`Http2ConnectionHandler` or `Http2FrameCodec`) should contain [SETTINGS_ENABLE_CONNECT_PROTOCOL=1](https://tools.ietf.org/html/rfc8441#section-9.1)
132166
parameter to advertise websocket-over-http2 support.
@@ -181,6 +215,12 @@ Events are fired on parent channel, also on websocket channel if one gets create
181215
* `Http2WebSocketHandshakeErrorEvent(webSocketId, path, subprotocols, timestampNanos, responseHeaders, error)`
182216
* `Http2WebSocketHandshakeSuccessEvent(webSocketId, path, subprotocols, timestampNanos, responseHeaders)`
183217

218+
These events are accompanied by transport agnostic variants
219+
220+
* `WebSocketHandshakeStartEvent(websocketId, path, subprotocols, timestampNanos, requestHeaders)`
221+
* `WebSocketHandshakeErrorEvent(webSocketId, path, subprotocols, timestampNanos, responseHeaders, error)`
222+
* `WebSocketHandshakeSuccessEvent(webSocketId, path, subprotocols, timestampNanos, responseHeaders)`
223+
184224
#### close events
185225

186226
Outbound `Http2WebSocketLocalCloseEvent` on websocket channel pipeline closes
@@ -265,7 +305,7 @@ the results are as follows (measured over time spans of 5 seconds):
265305

266306
* `channelserver, channelclient` packages for websocket subchannel API demos.
267307
* `handshakeserver, channelclient` packages for handshake only API demo.
268-
* `multiprotocolserver, multiprotocolclient` packages for demo of server handling htt1/http2 websockets on the same port.
308+
* `multiprotocol` packages for demo of server handling htt1/http2 websockets on the same port.
269309
* `lwsclient` package for client demo that runs against [https://libwebsockets.org/testserver/](https://libwebsockets.org/testserver/) which hosts websocket-over-http2
270310
server implemented with [libwebsockets](https://github.com/warmcat/libwebsockets) - popular C-based networking library.
271311

@@ -286,7 +326,7 @@ repositories {
286326
}
287327
288328
dependencies {
289-
implementation 'com.jauntsdn.netty:netty-websocket-http2:1.2.5'
329+
implementation 'com.jauntsdn.netty:netty-websocket-http2:1.2.6'
290330
}
291331
```
292332

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ subprojects {
3838

3939
repositories {
4040
mavenCentral()
41+
mavenLocal()
4142
}
4243

4344
plugins.withType(JavaPlugin) {

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
group=com.jauntsdn.netty
2-
version=1.2.6
2+
version=1.3.0
33

44
googleJavaFormatPluginVersion=0.9
55
dependencyManagementPluginVersion=1.1.0
66
gitPluginVersion=0.13.0
77
osDetectorPluginVersion=1.7.3
88
versionsPluginVersion=0.45.0
99

10-
nettyVersion=4.1.109.Final
11-
jauntNettyWebsocketHttp1=1.1.4
10+
nettyVersion=4.1.112.Final
11+
jauntNettyWebsocketHttp1=1.2.0
1212
nettyTcnativeVersion=2.0.65.Final
1313
hdrHistogramVersion=2.1.12
1414
slf4jVersion=1.7.36

multiprotocol_callbacks_server.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
./gradlew netty-websocket-http2-example:runMultiProtocolCallbacksServer

multiprotocol_default_server.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
./gradlew netty-websocket-http2-example:runMultiProtocolDefaultServer

multiprotocol_server.sh

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

netty-websocket-http2-callbacks-codec/gradle.lockfile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ com.google.errorprone:javac-shaded:9+181-r4173-1=googleJavaFormat1.6
77
com.google.googlejavaformat:google-java-format:1.6=googleJavaFormat1.6
88
com.google.guava:guava:22.0=googleJavaFormat1.6
99
com.google.j2objc:j2objc-annotations:1.1=googleJavaFormat1.6
10-
com.jauntsdn.netty:netty-websocket-http1:1.1.4=compileClasspath
11-
io.netty:netty-buffer:4.1.109.Final=compileClasspath
12-
io.netty:netty-codec-http2:4.1.109.Final=compileClasspath
13-
io.netty:netty-codec-http:4.1.109.Final=compileClasspath
14-
io.netty:netty-codec:4.1.109.Final=compileClasspath
15-
io.netty:netty-common:4.1.109.Final=compileClasspath
16-
io.netty:netty-handler:4.1.109.Final=compileClasspath
17-
io.netty:netty-resolver:4.1.109.Final=compileClasspath
18-
io.netty:netty-transport-native-unix-common:4.1.109.Final=compileClasspath
19-
io.netty:netty-transport:4.1.109.Final=compileClasspath
10+
com.jauntsdn.netty:netty-websocket-http1:1.2.0=compileClasspath
11+
io.netty:netty-buffer:4.1.112.Final=compileClasspath
12+
io.netty:netty-codec-http2:4.1.112.Final=compileClasspath
13+
io.netty:netty-codec-http:4.1.112.Final=compileClasspath
14+
io.netty:netty-codec:4.1.112.Final=compileClasspath
15+
io.netty:netty-common:4.1.112.Final=compileClasspath
16+
io.netty:netty-handler:4.1.112.Final=compileClasspath
17+
io.netty:netty-resolver:4.1.112.Final=compileClasspath
18+
io.netty:netty-transport-native-unix-common:4.1.112.Final=compileClasspath
19+
io.netty:netty-transport:4.1.112.Final=compileClasspath
2020
org.codehaus.mojo:animal-sniffer-annotations:1.14=googleJavaFormat1.6
2121
empty=annotationProcessor

netty-websocket-http2-example/build.gradle

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ description = "Netty based implementation of rfc8441 - bootstrapping websockets
2222

2323
dependencies {
2424
implementation project(":netty-websocket-http2")
25+
implementation project(":netty-websocket-multiprotocol")
26+
implementation project(":netty-websocket-http2-callbacks-codec")
2527
implementation "org.slf4j:slf4j-api"
2628
runtimeOnly "io.netty:netty-tcnative-boringssl-static::${osdetector.classifier}"
2729
runtimeOnly "ch.qos.logback:logback-classic"
@@ -37,9 +39,14 @@ task runChannelServer(type: JavaExec) {
3739
mainClass = "com.jauntsdn.netty.handler.codec.http2.websocketx.example.channelserver.Main"
3840
}
3941

40-
task runMultiProtocolServer(type: JavaExec) {
42+
task runMultiProtocolDefaultServer(type: JavaExec) {
4143
classpath = sourceSets.main.runtimeClasspath
42-
mainClass = "com.jauntsdn.netty.handler.codec.http2.websocketx.example.multiprotocolserver.Main"
44+
mainClass = "com.jauntsdn.netty.handler.codec.http2.websocketx.example.multiprotocol.server.defaultcodec.Main"
45+
}
46+
47+
task runMultiProtocolCallbacksServer(type: JavaExec) {
48+
classpath = sourceSets.main.runtimeClasspath
49+
mainClass = "com.jauntsdn.netty.handler.codec.http2.websocketx.example.multiprotocol.server.callbackscodec.Main"
4350
}
4451

4552
task runChannelClient(type: JavaExec) {
@@ -54,6 +61,6 @@ task runLwsClient(type: JavaExec) {
5461

5562
task runMultiProtocolClient(type: JavaExec) {
5663
classpath = sourceSets.main.runtimeClasspath
57-
mainClass = "com.jauntsdn.netty.handler.codec.http2.websocketx.example.multiprotocolclient.Main"
64+
mainClass = "com.jauntsdn.netty.handler.codec.http2.websocketx.example.multiprotocol.client.Main"
5865
}
5966

netty-websocket-http2-example/src/main/java/com/jauntsdn/netty/handler/codec/http2/websocketx/example/Security.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717
package com.jauntsdn.netty.handler.codec.http2.websocketx.example;
1818

1919
import io.netty.handler.codec.http2.Http2SecurityUtil;
20-
import io.netty.handler.ssl.*;
20+
import io.netty.handler.ssl.ApplicationProtocolConfig;
21+
import io.netty.handler.ssl.ApplicationProtocolNames;
22+
import io.netty.handler.ssl.OpenSsl;
23+
import io.netty.handler.ssl.SslContext;
24+
import io.netty.handler.ssl.SslContextBuilder;
25+
import io.netty.handler.ssl.SslProvider;
26+
import io.netty.handler.ssl.SupportedCipherSuiteFilter;
2127
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
2228
import java.io.InputStream;
2329
import java.security.KeyStore;

0 commit comments

Comments
 (0)