hypercorn icon indicating copy to clipboard operation
hypercorn copied to clipboard

AssertionError: first packet must be INITIAL when using multiple workers with HTTP3 (QUIC)

Open sinwoobang opened this issue 1 year ago • 0 comments

Issue Description

I encountered an issue while using the hypercorn library with multiple workers and HTTP3 (QUIC) support. When I attempt to configure both workers and quic-bind together, an error is raised with the following message:

AssertionError: first packet must be INITIAL

Steps to reproduce

  1. Configure hypercorn to use multiple workers and enable HTTP3 support.
  2. Start the server.
  3. Use an h3 client (e.g., curl) to send a request to the server.

Observed behavior

The aioquic library, which is used by hypercorn for HTTP3 support, raises an AssertionError. This is because it expects the first packet to be of type INITIAL. However, after inspecting the traffic with Wireshark, it appears that the INITIAL packet is being transmitted normally. Here is a packet log dumped with Wireshark.

1	0.000000	127.0.0.1	127.0.0.1	QUIC	1232	Initial, DCID=66505fb628555f9fabcbecfc84c6e767, SCID=5cb6d6c8a86ece38423e5e062fa30b05af47a6f6, PKN: 0, CRYPTO

The issue seems to be related to the fact that each worker is running in their own process, and they might not be aware of each other's connection states. For example, Worker A might receive the INITIAL packet, but Worker B receives the following packets and raises the error because it has not seen the INITIAL packet.

Expected behavior

The server should be able to handle HTTP3 connections properly when using multiple workers.

Possible solutions

I'm not sure if using workers and quic-bind together is a valid configuration or if I'm using it incorrectly. If this is a bug, please consider investigating and addressing the issue. If it's not a bug and I'm misusing the configuration, please let me know the proper way to use it.

Client Information

HTTP3

curl 8.0.0-DEV (aarch64-apple-darwin22.1.0) libcurl/8.0.0-DEV (SecureTransport) BoringSSL zlib/1.2.11 brotli/1.0.9 zstd/1.5.4 libidn2/2.3.4 libssh2/1.10.0 nghttp2/1.52.0 quiche/0.16.0 librtmp/2.3
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL threadsafe UnixSockets zstd

Hypercorn & aioquic

aioquic==0.9.20
hypercorn==0.14.3

Thank you!

sinwoobang avatar Mar 21 '23 07:03 sinwoobang