Fix WebTransport server implementation and add test client

Server fixes:
- Move H3Connection initialization to ProtocolNegotiated event (matches official aioquic pattern)
- Fix datagram routing to use session_id instead of flow_id
- Add max_datagram_frame_size=65536 to enable QUIC datagrams
- Fix send_datagram() to use keyword arguments
- Add certificate chain handling for Let's Encrypt
- Add no-cache headers to static server

Command-line improvements:
- Move settings from environment variables to argparse
- Add comprehensive CLI arguments with defaults
- Default mode=wt, cert=cert.pem, key=key.pem

Test clients:
- Add test_webtransport_client.py - Python WebTransport client that successfully connects
- Add test_http3.py - Basic HTTP/3 connectivity test

Client updates:
- Auto-configure server URL and certificate hash from /cert-hash.json
- Add ES6 module support

Status:
 Python WebTransport client works perfectly
 Server properly handles WebTransport connections and datagrams
 Chrome fails due to cached QUIC state (QUIC_IETF_GQUIC_ERROR_MISSING)
🔍 Firefox sends packets but fails differently - to be debugged next session

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vladyslav Doloman
2025-10-19 23:50:08 +00:00
parent ed5cb14b30
commit 1de5a8f3e6
9 changed files with 890 additions and 147 deletions

59
test_http3.py Normal file
View File

@@ -0,0 +1,59 @@
#!/usr/bin/env python3
"""Simple HTTP/3 client to test the server."""
import asyncio
import logging
from aioquic.asyncio import connect
from aioquic.quic.configuration import QuicConfiguration
logging.basicConfig(level=logging.DEBUG)
async def test_http3(url: str):
"""Test HTTP/3 connection to the server."""
print(f"Testing HTTP/3 connection to: {url}")
# Parse URL
if url.startswith("https://"):
url = url[8:]
host, port = url.split(":")
port = int(port.rstrip("/"))
print(f"Connecting to {host}:{port}...")
# Create QUIC configuration
configuration = QuicConfiguration(
is_client=True,
alpn_protocols=["h3"],
verify_mode=0 # Skip certificate verification for testing
)
try:
async with connect(
host,
port,
configuration=configuration,
) as protocol:
print(f"✓ QUIC connection established!")
print(f" ALPN protocol: {protocol._quic.tls.alpn_negotiated}")
print(f" Remote address: {protocol._quic.remote_address}")
# Just test the connection, don't send HTTP requests yet
await asyncio.sleep(1)
print("✓ Connection successful!")
return True
except Exception as e:
print(f"✗ Connection failed: {e}")
import traceback
traceback.print_exc()
return False
if __name__ == "__main__":
import sys
url = sys.argv[1] if len(sys.argv) > 1 else "https://127.0.0.1:4433"
success = asyncio.run(test_http3(url))
sys.exit(0 if success else 1)