Skip to content

WebSocket upgrade succeeds then server closes with 1008 Policy (falls back to HTTPS) #13041

Closed

Description

@kali113

Codex WebSocket fallback report (sanitized)

Summary

Codex websocket transport to wss://chatgpt.com/backend-api/codex/responses upgrades successfully and is then immediately closed by server policy (1008), leading to reconnect loop and fallback to HTTPS.

Environment

  • OS: Arch Linux (x86_64), kernel 6.18.9-arch1-2
  • Codex CLI: 0.106.0 (also reproduced on 0.107.0-alpha.5)
  • Node: v25.7.0
  • npm: 11.10.1
  • Auth: ChatGPT login mode
  • Features enabled:
    • responses_websockets_v2 = true
    • realtime_conversation = true
    • voice_transcription = true

Repro

codex exec -C /home/arch --skip-git-repo-check --json "Reply with exactly: WS_FINAL_CHECK"

Expected

Websocket transport should remain open and stream should proceed without fallback.

Actual

  • Reconnecting retries (2/5..5/5)
  • Fallback message:
    • Falling back from WebSockets to HTTPS transport. stream disconnected before completion...

Key sanitized evidence

INFO  connecting to websocket: wss://chatgpt.com/backend-api/codex/responses
INFO  successfully connected to websocket: wss://chatgpt.com/backend-api/codex/responses
DEBUG Received close frame: Some(CloseFrame { code: Policy, reason: Utf8Bytes(b"") })
... reconnect loop ...
Falling back from WebSockets to HTTPS transport ...

What was ruled out

  • Reproduces on stable + alpha codex CLI.
  • Reproduces on responses_websockets_v2 and legacy responses_websockets.
  • No HTTP_PROXY/HTTPS_PROXY env vars configured.

Attachments (sanitized)

  • Evidence is posted inline in issue comments (no local-file dependency).

Activity

  1. github-actions commented on Feb 27, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  2. kali113 commented on Feb 27, 2026

    @kali113
    Author

    Maintainer note: local paths like /tmp/... in the issue body are not externally accessible. Posting sanitized evidence inline below.

    Sanitized websocket policy-close trace

    2026-02-27T18:27:54.791212Z  INFO codex_api::endpoint::responses_websocket: connecting to websocket: wss://chatgpt.com/backend-api/codex/responses
    2026-02-27T18:27:55.174925Z  INFO codex_api::endpoint::responses_websocket: successfully connected to websocket: wss://chatgpt.com/backend-api/codex/responses
    2026-02-27T18:27:55.176795Z DEBUG tungstenite::protocol: Received close frame: Some(CloseFrame { code: Policy, reason: Utf8Bytes(b"") })
    2026-02-27T18:27:55.182285Z  INFO codex_api::endpoint::responses_websocket: connecting to websocket: wss://chatgpt.com/backend-api/codex/responses
    2026-02-27T18:27:55.606312Z  INFO codex_api::endpoint::responses_websocket: successfully connected to websocket: wss://chatgpt.com/backend-api/codex/responses
    2026-02-27T18:27:55.611381Z DEBUG tungstenite::protocol: Received close frame: Some(CloseFrame { code: Policy, reason: Utf8Bytes(b"") })
    2026-02-27T18:27:55.822204Z  INFO codex_api::endpoint::responses_websocket: connecting to websocket: wss://chatgpt.com/backend-api/codex/responses
    2026-02-27T18:27:56.332352Z  INFO codex_api::endpoint::responses_websocket: successfully connected to websocket: wss://chatgpt.com/backend-api/codex/responses
    2026-02-27T18:27:56.339828Z DEBUG tungstenite::protocol: Received close frame: Some(CloseFrame { code: Policy, reason: Utf8Bytes(b"") })
    Reconnecting... 2/5 (stream disconnected before completion: websocket closed by server before response.completed)
    2026-02-27T18:27:56.725861Z  INFO codex_api::endpoint::responses_websocket: connecting to websocket: wss://chatgpt.com/backend-api/codex/responses
    2026-02-27T18:27:57.021299Z  INFO codex_api::endpoint::responses_websocket: successfully connected to websocket: wss://chatgpt.com/backend-api/codex/responses
    2026-02-27T18:27:57.021518Z DEBUG tungstenite::protocol: Received close frame: Some(CloseFrame { code: Policy, reason: Utf8Bytes(b"") })
    Reconnecting... 3/5 (stream disconnected before completion: failed to send websocket request: Connection closed normally)
    2026-02-27T18:27:57.760883Z  INFO codex_api::endpoint::responses_websocket: connecting to websocket: wss://chatgpt.com/backend-api/codex/responses
    2026-02-27T18:27:58.126456Z  INFO codex_api::endpoint::responses_websocket: successfully connected to websocket: wss://chatgpt.com/backend-api/codex/responses
    2026-02-27T18:27:58.126738Z DEBUG tungstenite::protocol: Received close frame: Some(CloseFrame { code: Policy, reason: Utf8Bytes(b"") })
    Reconnecting... 4/5 (stream disconnected before completion: failed to send websocket request: Connection closed normally)
    2026-02-27T18:27:59.871851Z  INFO codex_api::endpoint::responses_websocket: connecting to websocket: wss://chatgpt.com/backend-api/codex/responses
    2026-02-27T18:28:00.243959Z  INFO codex_api::endpoint::responses_websocket: successfully connected to websocket: wss://chatgpt.com/backend-api/codex/responses
    2026-02-27T18:28:00.244204Z DEBUG tungstenite::protocol: Received close frame: Some(CloseFrame { code: Policy, reason: Utf8Bytes(b"") })
    Reconnecting... 5/5 (stream disconnected before completion: failed to send websocket request: Connection closed normally)
    2026-02-27T18:28:03.562616Z  INFO codex_api::endpoint::responses_websocket: connecting to websocket: wss://chatgpt.com/backend-api/codex/responses
    2026-02-27T18:28:03.930484Z  INFO codex_api::endpoint::responses_websocket: successfully connected to websocket: wss://chatgpt.com/backend-api/codex/responses
    2026-02-27T18:28:03.930770Z DEBUG tungstenite::protocol: Received close frame: Some(CloseFrame { code: Policy, reason: Utf8Bytes(b"") })
    {"type":"item.completed","item":{"id":"item_1","type":"error","message":"Falling back from WebSockets to HTTPS transport. stream disconnected before completion: failed to send websocket request: Connection closed normally"}}
    

    Sanitized codex exec --json output

    {"type":"thread.started","thread_id":"019ca058-ef8b-7a40-9cad-64885362c9f9"}
    {"type":"item.completed","item":{"id":"item_0","type":"error","message":"Under-development features enabled: realtime_conversation, responses_websockets_v2, voice_transcription. Under-development features are incomplete and may behave unpredictably. To suppress this warning, set `suppress_unstable_features_warning = true` in /home/arch/.codex/config.toml."}}
    {"type":"turn.started"}
    {"type":"error","message":"Reconnecting... 2/5 (stream disconnected before completion: failed to send websocket request: Connection closed normally)"}
    {"type":"error","message":"Reconnecting... 3/5 (stream disconnected before completion: failed to send websocket request: Connection closed normally)"}
    {"type":"error","message":"Reconnecting... 4/5 (stream disconnected before completion: failed to send websocket request: Connection closed normally)"}
    {"type":"error","message":"Reconnecting... 5/5 (stream disconnected before completion: failed to send websocket request: Connection closed normally)"}
    {"type":"item.completed","item":{"id":"item_1","type":"error","message":"Falling back from WebSockets to HTTPS transport. stream disconnected before completion: failed to send websocket request: Connection closed normally"}}
    {"type":"item.completed","item":{"id":"item_2","type":"reasoning","text":"**Preparing final output**"}}
    {"type":"item.completed","item":{"id":"item_3","type":"agent_message","text":"WS_FINAL_CHECK"}}
    {"type":"turn.completed","usage":{"input_tokens":9350,"cached_input_tokens":8320,"output_tokens":49}}
  3. kali113 commented on Feb 27, 2026

    @kali113
    Author

    @pakrym-oai Follow-up with corrected formatting from my previous comment:

    Repro is outside corporate environment (no corporate proxy/VPN), and proxy env vars are unset.

    Observed behavior remains: websocket upgrade succeeds, then server immediately closes with 1008 Policy, and client falls back to HTTPS after retries.

    If useful, I can run any additional diagnostics you want on this machine/account.

  4. bruno-ortiz commented on Feb 27, 2026

    @bruno-ortiz

    Just to add to the report: I can confirm this is also happening on macOS Tahoe.
    I’m using the ChatGPT login flow. However, when I switch to API key authentication, the problem does not happen.

  5. etraut-openai commented on Feb 27, 2026

    @etraut-openai
    Contributor

    @bruno-ortiz, if you're able to reliably repro the failure, can you use /feedback to upload your logs and a sample session, then post the thread ID here? Thanks!

  6. bruno-ortiz commented on Feb 27, 2026

    @bruno-ortiz

    Hey @etraut-openai, here is the thread ID. 019ca10b-6a31-7bd0-9c2e-1a9d7f309f79. Let me know if I can help in any other way.

  7. etraut-openai commented on Feb 27, 2026

    @etraut-openai
    Contributor

    Thanks, I see the failure in your logs. Are you using a VPN or corporate network proxy?

  8. jordyvandomselaar commented on Feb 28, 2026

    @jordyvandomselaar

    Another thread ID: 019ca197-45c7-7700-a15c-ae5d694daefe

    Not on a VPN or a proxy =)

  9. VisionaryOS commented on Feb 28, 2026

    @VisionaryOS

    same: Falling back from WebSockets to HTTPS transport. stream disconnected before completion: websocket closed by server before response.completed

  10. bruno-ortiz commented on Feb 28, 2026

    @bruno-ortiz

    @etraut-openai no vpn or proxy.

  11. killianMei commented on Feb 28, 2026

    @killianMei

    same: codex app 26.227.1448 (747)

  12. PerryFinn commented on Feb 28, 2026

    @PerryFinn

    We encountered the same problem on Mac, but we used the company's VPN.

  13. canberksinangil commented on Feb 28, 2026

    @canberksinangil

    Same here, no VPN or Proxy @etraut-openai
    I hope this helps > 019ca36e-6685-7791-a1d6-9b8cfe5e8a3f

    Image
  14. kali113 commented on Feb 28, 2026

    @kali113
    Author

    @etraut-openai no vpn or proxy. the thread ID is 019ca37b-863f-72a3-958a-799e338cc67a

    Image
  15. sPredictorX1708 commented on Feb 28, 2026

    @sPredictorX1708

    +1 facing the same problem. How to solve it?

  16. 56 remaining items

  17. artemgetmann commented on May 27, 2026

    @artemgetmann

    still happening. for me also

  18. aminekechaou commented on May 27, 2026

    @aminekechaou

    the workaround mentioned here worked for me. It is however much slower than with websockets (and even when using fast mode)

  19. ptanner2022 commented on Jun 5, 2026

    @ptanner2022

    Having this issue on aws ec2 ubuntu

  20. kaansoral commented on Jun 14, 2026

    @kaansoral

    This issue is a regular for me, my codex is always the latest version - MacOS Tahoe 26.4

    Falling back from WebSockets to HTTPS transport. stream disconnected before completion: websocket
    closed by server before response.completed

    Edit: With a bit of debugging - my likely cause is overloading the context with a single message - likely by sending images (likely when compaction was near)

  21. m1cham0v commented on Jun 16, 2026

    @m1cham0v

    Ditto +1

    OS: Arch Linux (x86_64), kernel 7.0.11-arch1-1
    Codex CLI: openai-codex 0.140.0-1
    Node: v26.2.0
    npm: 11.17.0

  22. diegomrsantos commented on Jul 2, 2026

    @diegomrsantos
    Reconnecting 2/5
    stream disconnected before completion: idle timeout waiting for websocket
    

    I get this very often; it's incredibly frustrating.

  23. Unknown47Dream commented on Sep 14, 2026

    @Unknown47Dream

    this is still happening, how this is closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingconnectivityIssues involving networking or endpoint connectivity problems (disconnections)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions