# Fix: 2-Second HTTP Request Delay ## Problem Found! Your logs show: ``` [Server Sync] HTTP request: 2045ms, Status: 200 ← 2 seconds in Python! [2025-12-27...] Transcription received: "..." (total: 40ms) ← 40ms in Node.js! ``` **The server processes in 40ms, but the HTTP request takes 2000ms!** ## Root Cause: DNS Resolution Delay You're using `http://localhost:3000/api/send`, and on **WSL2** (Windows Subsystem for Linux), DNS resolution of `localhost` is VERY slow (~2 seconds). This is a known issue with WSL2 networking. ## Solution: Use 127.0.0.1 Instead ### Fix in Desktop App Settings 1. Open Local Transcription app 2. Go to **Settings** → **Server Sync** 3. Change Server URL from: ``` http://localhost:3000/api/send ``` To: ``` http://127.0.0.1:3000/api/send ``` 4. Click **Save** 5. Restart transcription **Expected result:** HTTP requests drop from 2045ms → ~50ms! --- ## Why This Happens ### On WSL2: ``` localhost → [DNS lookup via Windows] → [WSL network translation] → 127.0.0.1 ↑ This takes 2 seconds! ↑ ``` ### Direct IP: ``` 127.0.0.1 → [Direct connection] → Node.js server ↑ Fast! ↑ ``` --- ## Alternative Fixes ### Option 1: Fix WSL2 DNS (Advanced) Edit `/etc/wsl.conf`: ```bash sudo nano /etc/wsl.conf ``` Add: ```ini [network] generateResolvConf = false ``` Then edit `/etc/resolv.conf`: ```bash sudo nano /etc/resolv.conf ``` Change to: ``` nameserver 8.8.8.8 nameserver 8.8.4.4 ``` Restart WSL: ```powershell # In Windows PowerShell: wsl --shutdown ``` ### Option 2: Add to /etc/hosts ```bash sudo nano /etc/hosts ``` Add: ``` 127.0.0.1 localhost ::1 localhost ``` ### Option 3: Just Use 127.0.0.1 (Easiest!) No system changes needed - just use the IP address everywhere: - Server URL: `http://127.0.0.1:3000/api/send` - Display URL: `http://127.0.0.1:3000/display?room=...` --- ## Verification After changing to `127.0.0.1`, you should see: **Before:** ``` [Server Sync] HTTP request: 2045ms, Status: 200 ``` **After:** ``` [Server Sync] HTTP request: 45ms, Status: 200 ``` **Total improvement:** 2 seconds faster! ✅ --- ## For OBS Users Also update your OBS Browser Source URL: **Old:** ``` http://localhost:3000/display?room=cosmic-nebula-5310&fade=10 ``` **New:** ``` http://127.0.0.1:3000/display?room=cosmic-nebula-5310&fade=10 ``` --- ## Why Node.js Generates with localhost The room generator in Node.js uses `localhost` because: ```javascript const serverUrl = `http://${window.location.host}/api/send`; ``` If you access the page via `http://127.0.0.1:3000`, it will generate URLs with `127.0.0.1`. If you access via `http://localhost:3000`, it will generate with `localhost`. **Recommendation:** Always access the Node.js page via: ``` http://127.0.0.1:3000 ``` Then the room generator will create fast URLs automatically! --- ## Summary | Method | Speed | Notes | |--------|-------|-------| | `http://localhost:3000/api/send` | **2045ms** ❌ | Slow DNS on WSL2 | | `http://127.0.0.1:3000/api/send` | **45ms** ✅ | Direct IP, no DNS | | Fix WSL2 DNS | Varies | Complex, may break other things | **Just use 127.0.0.1 everywhere - problem solved!** 🚀