fix(start): force http2 protocol and drain cloudflared output 🐛
QUIC tunnels consistently returned 1033 errors. Forcing http2 fixes it. Added a daemon thread to drain cloudflared's stdout pipe to prevent buffer-full blocking that would kill the tunnel.
This commit is contained in:
parent
f2cfe72d63
commit
7288d93741
1 changed files with 9 additions and 1 deletions
10
start.py
10
start.py
|
|
@ -12,6 +12,7 @@ import re
|
|||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import pathlib
|
||||
|
||||
|
|
@ -62,7 +63,7 @@ def start_server(port: int, bot_token: str) -> subprocess.Popen:
|
|||
def start_tunnel(port: int) -> tuple[subprocess.Popen, str]:
|
||||
print(f" Starting tunnel to port {port}...")
|
||||
proc = subprocess.Popen(
|
||||
["cloudflared", "tunnel", "--url", f"http://localhost:{port}"],
|
||||
["cloudflared", "tunnel", "--url", f"http://localhost:{port}", "--protocol", "http2"],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True,
|
||||
|
|
@ -95,6 +96,13 @@ def start_tunnel(port: int) -> tuple[subprocess.Popen, str]:
|
|||
print(" Make sure cloudflared is installed: cloudflared tunnel --url http://localhost:8080\n")
|
||||
sys.exit(1)
|
||||
|
||||
# Keep draining cloudflared output so its pipe buffer doesn't fill up
|
||||
# (which would block the process and kill the tunnel)
|
||||
def _drain():
|
||||
for line in proc.stdout:
|
||||
pass
|
||||
threading.Thread(target=_drain, daemon=True).start()
|
||||
|
||||
return proc, url
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue