codex - 💡(How to fix) Fix WebSocket connection fails due to HTTP/2 ALPN negotiation - needs HTTP Compatibility Mode like Cursor

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

When Codex establishes a WebSocket connection to api.openai.com/v1/realtime, the TLS ClientHello offers both h2 and http/1.1 via ALPN. The server selects h2, but WebSocket Upgrade is an HTTP/1.1-only mechanism, so the server returns HTTP/2 405 instead of 101 Switching Protocols.

RAW_BUFFERClick to expand / collapse

Problem

Codex desktop app WebSocket connection fails with repeated "Reconnecting 1/5 ... 5/5" when using a proxy (VPN/TUN mode). The root cause is HTTP/2 ALPN negotiation.

Root Cause

When Codex establishes a WebSocket connection to api.openai.com/v1/realtime, the TLS ClientHello offers both h2 and http/1.1 via ALPN. The server selects h2, but WebSocket Upgrade is an HTTP/1.1-only mechanism, so the server returns HTTP/2 405 instead of 101 Switching Protocols.

Proof

Default (h2 negotiated) - FAILS:

curl -v -H "Upgrade: websocket" -H "Connection: Upgrade" -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" -H "Sec-WebSocket-Version: 13" "https://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview"

Result: ALPN: server accepted h2 using HTTP/2 HTTP/2 405 - Invalid method for URL (GET /v1/realtime)

Force HTTP/1.1 - SUCCEEDS:

curl -v --http1.1 -H "Upgrade: websocket" -H "Connection: Upgrade" -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" -H "Sec-WebSocket-Version: 13" "https://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview"

Result: ALPN: server accepted http/1.1 using HTTP/1.1 HTTP/1.1 101 Switching Protocols

Environment

  • Codex Desktop Windows
  • Proxy: V2Ray TUN mode
  • Issue is NOT network/IP blocking, forcing HTTP/1.1 works perfectly

Suggested Fix

Cursor already solved this with a built-in HTTP Compatibility Mode setting under Settings - Network - HTTP Compatibility Mode - HTTP/1.1.

Please add the same option to Codex, or force HTTP/1.1 when establishing WebSocket connections to api.openai.com/v1/realtime.

The Node.js fix would be:

const agent = new https.Agent({ ALPNProtocols: ['http/1.1'] }) const ws = new WebSocket(url, { agent, ...options })

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix WebSocket connection fails due to HTTP/2 ALPN negotiation - needs HTTP Compatibility Mode like Cursor