Skip to content

DeepSeek native Responses: upstream SSE socket closed unexpectedly (upstream_reset), deterministic #6187

Closed

Description

@cybertingzhen

Client or integration

Codex App

Provider or upstream service

deepseek

OpenCodex version

2.69.0

Endpoint or capability

streaming

Current behaviour

A request with stream:true deterministically ends in response.failed:
{"type":"upstream_error","code":"upstream_reset","message":"Upstream stream terminated unexpectedly: The socket connection was closed unexpectedly."}
Identical on every run. Via the ChatGPT client it surfaces as 502 upstream_server_error, failureStage=protocol-prelude, disconnecting after ~336ms.

Expected behaviour

The upstream SSE stream should stay alive — at least no worse than a direct curl, which streams DeepSeek /responses end-to-end without errors.

Minimal redacted request or reproduction

$b = @{ model = "deepseek/deepseek-flash"; input = "hi"; max_output_tokens = 10; stream = $true } | ConvertTo-Json -Depth 5
Invoke-RestMethod -Uri "http://localhost:10100/v1/responses" -Method Post -Body $b -ContentType "application/json" -TimeoutSec 60

Actual response or error

event: response.failed
data: {"type":"response.failed","response":{"status":"failed","error":{"type":"upstream_error","code":"upstream_reset","message":"Upstream stream terminated unexpectedly: The socket connection was closed unexpectedly."}}}
data: [DONE]
 HTTP 502 upstream_server_error.

Upstream documentation

https://api-docs.deepseek.com/guides/responses_api
Consider re-applying the bounded-JSON upstream policy (#1026) for DeepSeek as a fallback when upstream SSE fails in proxied environments.

Suggested mapping or implementation notes

No response

Additional context and attachments

Checks

  • I searched existing provider and compatibility issues.
  • The request and response were redacted.
  • The expected behaviour is based on an upstream specification or a concrete client requirement.

Activity

  1. cybertingzhen commented on Sep 28, 2026

    @cybertingzhen
    Author

    Update: worked around it locally.

    Root cause in my environment: Clash (Mihomo) fake-ip DNS returns 198.18.0.0/15 for api.deepseek.com, and OpenCodex's direct connection to the fake IP got its upstream SSE socket killed.

    Workaround: set an explicit outbound proxy on the deepseek provider in config.json:
    "proxy": "http://127.0.0.1:7897"
    (per #2037 this arms the allowBenchmarkAddresses opt-in, so the hostname rides the proxy CONNECT instead of the fake IP)

    After that, the minimal stream:true repro returns a complete SSE stream — no more upstream_reset.

    Note: my provider already had "allowPrivateNetwork": true, which alone was not sufficient; the explicit proxy is what fixed it.

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

    providerProvider adapters, OpenAI-compat presets, upstream API quirksprovider-compatibilityProvider compatibility reportsstreamingSSE, WebSocket, terminal stream frames

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions