Jetty的http3模組

jackieathome發表於2024-03-10

啟用http3模組,執行如下命令:

java -jar $JETTY_HOME/start.jar --add-modules=http3

命令的輸出,如下:

ALERT: There are enabled module(s) with licenses.
The following 2 module(s):
 + contains software not provided by the Eclipse Foundation!
 + contains software not covered by the Eclipse Public License!
 + has not been audited for compliance with its license

 Module: jna
  + Java Native Access (JNA) is licensed under the LGPL, version 2.1
  + or later, or (from version 4.0 onward) the Apache License,
  + version 2.0.
  + You can freely decide which license you want to apply to the project.
  + You may obtain a copy of the LGPL License at:
  + http://www.gnu.org/licenses/licenses.html
  + A copy is also included in the downloadable source code package
  + containing JNA, in file "LGPL2.1", under the same directory
  + as this file.
  + You may obtain a copy of the Apache License at:
  + http://www.apache.org/licenses/
  + A copy is also included in the downloadable source code package
  + containing JNA, in file "AL2.0", under the same directory
  + as this file.

 Module: quiche
  + Redistribution and use in source and binary forms, with or without
  + modification, are permitted provided that the following conditions are met:
  + * Redistributions of source code must retain the above copyright
  + notice, this list of conditions and the following disclaimer.
  + * Redistributions in binary form must reproduce the above copyright
  + notice, this list of conditions and the following disclaimer in the
  + documentation and/or other materials provided with the distribution.
  + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
  + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Proceed (y/N)? y
INFO  : alpn-java       transitively enabled
INFO  : alpn            transitively enabled, ini template available with --add-modules=alpn
INFO  : work            transitively enabled
INFO  : http2           transitively enabled, ini template available with --add-modules=http2
INFO  : http3           initialized in ${jetty.base}/start.d/http3.ini
INFO  : jna             transitively enabled
INFO  : ssl             transitively enabled, ini template available with --add-modules=ssl
INFO  : quiche          transitively enabled
INFO  : mkdir ${jetty.base}/work
INFO  : mkdir ${jetty.base}/lib/http3
INFO  : download https://repo1.maven.org/maven2/net/java/dev/jna/jna-jpms/5.14.0/jna-jpms-5.14.0.jar to ${jetty.base}/lib/http3/jna-jpms-5.14.0.jar
INFO  : download https://repo1.maven.org/maven2/org/mortbay/jetty/quiche/jetty-quiche-native/0.20.0/jetty-quiche-native-0.20.0.jar to ${jetty.base}/lib/http3/jetty-quiche-native-0.20.0.jar
INFO  : Base directory was modified

http3模組的配置檔案$JETTY_BASE/start.d/http3.ini,內容如下:

# ---------------------------------------
# Module: http3
# Enables experimental support for the HTTP/3 protocol.
# ---------------------------------------
--modules=http3

## The host/address to bind the connector to.
# jetty.quic.host=0.0.0.0

## The port the connector listens on.
# jetty.quic.port=8444

## The connector idle timeout, in milliseconds.
# jetty.quic.idleTimeout=30000

## Specifies the maximum number of concurrent requests per session.
# jetty.quic.maxBidirectionalRemoteStreams=128

## Specifies the session receive window (client to server) in bytes.
# jetty.quic.sessionRecvWindow=4194304

## Specifies the stream receive window (client to server) in bytes.
# jetty.quic.bidirectionalStreamRecvWindow=2097152

## Specifies the stream idle timeout, in milliseconds.
# jetty.http3.streamIdleTimeout=30000

  • jetty.quic.host
    監聽服務的主機地址,預設值為0.0.0.0,即在本機所有的IP地址上監聽連結的請求。
  • jetty.quic.idleTimeout
    連結的空閒時長,單位:毫秒,預設值為30000,即30秒。
  • jetty.quic.maxBidirectionalRemoteStreams
    單個會話中允許並行發起的請求的數量。預設值為128
  • jetty.quic.sessionRecvWindow
    會話的接收資料的視窗,單位:位元組。預設值為4194304
  • jetty.quic.bidirectionalStreamRecvWindow
    雙向傳輸時接收資料的視窗,緩衝區的大小,單位:位元組。預設值為2097152
  • jetty.http3.streamIdleTimeout
    單位:毫秒,預設值為30000,即30秒。

參考資料

  • HTTP/3核心概念之QUIC
  • Quic協議(一)------HTTP3基礎之QUIC協議介紹
  • 5 分鐘看懂 HTTP3
  • RFC 9000 QUIC: A UDP-Based Multiplexed and Secure Transport
  • QUIC 開源實現列表
  • QUIC-HTTP/3介紹
  • HTTP 3.0之QUIC優勢和TCP弊端
  • [技術更新]Http/3 QUIC 基礎
  • 概念回顧:QUIC 和 HTTP/3

相關文章