Skip to content

stream_curl: retry a request whose connection drops before the headers - #18912

Open
SHR1F wants to merge 1 commit into
mpv-player:masterfrom
SHR1F:fix-curl-retry
Open

SHR1F wants to merge 1 commit into
mpv-player:masterfrom
SHR1F:fix-curl-retry

Conversation

@SHR1F

@SHR1F SHR1F commented Nov 27, 2026

Copy link
Copy Markdown

When the connection failed before any response headers arrived, the open failed at once without a retry. This happens when libcurl reuses a pooled connection that the server or a reverse proxy closed while idle.

Before the headers, a receive or send error or an empty reply now sends the request again, counted against --curl-max-retries. Errors that mean the server can't be reached, such as a failed connect or name lookup, still fail the open at once.

Tested on Windows (MSYS2 UCRT64, libcurl 8.23.0) with the server from #18695:

  • one reset: retries once, then plays to the end (before: Errors when loading file)
  • 10 resets: retries 5 times, then fails without hanging
  • nothing listening on the port: fails at once, no retry

Fixes #18695

AI disclosure: drafted with the OpenAI Codex CLI (gpt-6.2-sol), then cut down to this minimal change and tested with Claude Code (Claude Opus 5.5).

When the connection failed before any response headers arrived, the
error was logged and the open failed at once. Failures after the headers
go through the retry path, so only this early case was never retried.

It happens when libcurl reuses a pooled connection that the server or a
reverse proxy closed while it was idle: the request fails with a receive
or send error, or with an empty reply, before any headers.

Send the request again in that case, counted against
--curl-max-retries like the other retries. Errors that mean the server
cannot be reached, such as a failed connect or name lookup, still fail
the open at once.

Fixes: mpv-player#18695
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stream_curl: open fails without retry when the connection drops before the response headers

1 participant