Skip to content

Cmdline arg -to changes http read timeout from current 600sec default - #18279

Merged
ngxson merged 3 commits into
ggml-org:masterfrom
wbtek:wbtek/server-timeout-extension
Dec 29, 2025
Merged

ngxson merged 3 commits into
ggml-org:masterfrom
wbtek:wbtek/server-timeout-extension

Conversation

@wbtek

@wbtek wbtek commented Dec 22, 2025 •

Copy link
Copy Markdown
Contributor

llama-server has a hard-coded HTTP timeout of 300 seconds (the http library default). If the prompt and input files take longer than this timeout to process, the connection times out and is dropped, the WebUI gets out of sync, etc.

It is easy to exceed 300 (or 600) seconds on consumer hardware.

This PR reads the --timeout (-to) command-line argument. The default for --timeout is 600 seconds, twice as long as the http library's 300 seconds. The value of --timeout always overwrites the http library's default now. As a result, twice as long is now available by default. More is often needed though.

Huge timeouts can now be set with --timeout, circumventing this failure.

Note: Model unloading won't complete if cli->send() is active. A huge --timeout can make unloading impractical.

@ngxson ngxson left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the fix is correct but the comment is wrong: TTFT refers to time it takes from sending request to first token generated. it is made of:

  • time to read HTTP body
  • time to parse the request and do any pre-processing like tokenizer
  • time to wait for the LLM inference to start, stop, etc
  • time to send back the HTTP request

set_read_timeout is simply the timeout for reading HTTP body. it has nothing to do with LLM

@ngxson ngxson left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this won't work as-is because there is also a timeout imposed by the model instance in server-http.cpp

instead, please set the set_read_timeout and set_write_timeout according to the input params (do NOT hard-code it to 90 days)

srv->set_read_timeout (params.timeout_read);
srv->set_write_timeout(params.timeout_write);

Edit: for client cli, the set_write_timeout use be set to params.timeout_read (reversed to server)

@ngxson ngxson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep the code vertically aligned

Comment thread tools/server/server-models.cpp Resolved
@wbtek

wbtek commented Dec 22, 2025 •

Copy link
Copy Markdown
Contributor Author

@ngxson I changed the comment, changed the title, and --timeout is now used. From your comment, hopefully I didn't get the sense backwards for cli. Tell me if I did and I'll fix it.

Should there be a different solution for this?

That timeout is for communications. Processing time shouldn't affect this timeout at all, but it does.

We essentially have a watchdog with a time too long for stop and unload to be responsive, and too short for slow hardware.

I think we need:

  1. A way to reset the watchdog's timer (a heartbeat) and
  2. A way to terminate cli->send() immediately for cases like WebUI stop or unload.

@wbtek

wbtek commented Dec 22, 2025 •

Copy link
Copy Markdown
Contributor Author

keep the code vertically aligned

Yeah, that sux. Sry 'bout that. It looked ok before it got to github. Spacing fixed.

@wbtek

wbtek commented Dec 23, 2025 •

Copy link
Copy Markdown
Contributor Author

--- Testing ---
Model: Qwen3-Next-80B-A3B-Instruct-Q5_K_L.gguf (57G)
Attachments: 58k of llama-server C++ source code
Hardware: CPU only, Intel, 64G ram (It runs!)
Prompt: "What is 1+1?" (short answer wanted, test only requires one char to succeed)

  1. Shorten timeout using -to 77 proving code is using the command-line argument. Fails correctly at (77 seconds).

  2. Prove original and related problems are still corrected with prompt / attachments requiring >600 seconds before first response. Default timeout was from http library (300sec), but is now from llama-server (600sec). Set the timeout to a practical infinity with -to 7777777 (~90 days). The model responds after 780 seconds with no failure.

  3. Show default is now coming from llama-server (600sec). Same as test 2 with -to removed completely. The model fails correctly at exactly 600 seconds (10 minutes).

@wbtek
wbtek requested a review from ngxson December 23, 2025 10:01
@wbtek wbtek changed the title Prevent crash if TTFT >300sec, boosted to 90 days Prevent http fail if LLM doesn't respond in 300sec, use timeout (-to) cmdline arg to extend timeout Dec 24, 2025
@wbtek wbtek changed the title Prevent http fail if LLM doesn't respond in 300sec, use timeout (-to) cmdline arg to extend timeout Use -to cmdline arg to extend http timeout if LLM doesn't respond within default 300sec (now 600sec) Dec 24, 2025
@wbtek wbtek changed the title Use -to cmdline arg to extend http timeout if LLM doesn't respond within default 300sec (now 600sec) Use -to cmdline arg to extend http read timeout. Default now 600sec, was 300 Dec 24, 2025
@wbtek wbtek changed the title Use -to cmdline arg to extend http read timeout. Default now 600sec, was 300 Cmdline arg -to changes http read timeout from current 600sec default Dec 24, 2025
@ngxson
ngxson merged commit 5b1248c into ggml-org:master Dec 29, 2025
@wbtek
wbtek deleted the wbtek/server-timeout-extension branch January 5, 2026 11:58
blime4 referenced this pull request in blime4/llama.cpp Feb 5, 2026
…c default (#18279)

* Prevent crash if TTFT >300sec, boosted to 90 days

* server : allow configurable HTTP timeouts for child models

* server : pass needed timeouts from params only

---------

Co-authored-by: Greg Slocum <[email protected]>
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
…c default (ggml-org#18279)

* Prevent crash if TTFT >300sec, boosted to 90 days

* server : allow configurable HTTP timeouts for child models

* server : pass needed timeouts from params only

---------

Co-authored-by: Greg Slocum <[email protected]>
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
…c default (ggml-org#18279)

* Prevent crash if TTFT >300sec, boosted to 90 days

* server : allow configurable HTTP timeouts for child models

* server : pass needed timeouts from params only

---------

Co-authored-by: Greg Slocum <[email protected]>
fukuro-kun pushed a commit to fukuro-kun/fukuro-llama-cpp-turboquant that referenced this pull request Jul 5, 2026
…c default (ggml-org#18279)

* Prevent crash if TTFT >300sec, boosted to 90 days

* server : allow configurable HTTP timeouts for child models

* server : pass needed timeouts from params only

---------

Co-authored-by: Greg Slocum <[email protected]>
MrLordCat referenced this pull request in MrLordCat/llama.cpp-rdna-lab Jul 16, 2026
…c default (#18279)

* Prevent crash if TTFT >300sec, boosted to 90 days

* server : allow configurable HTTP timeouts for child models

* server : pass needed timeouts from params only

---------

Co-authored-by: Greg Slocum <[email protected]>
zommiommy pushed a commit to zommiommy/llama.cpp that referenced this pull request Aug 18, 2026
…c default (ggml-org#18279)

* Prevent crash if TTFT >300sec, boosted to 90 days

* server : allow configurable HTTP timeouts for child models

* server : pass needed timeouts from params only

---------

Co-authored-by: Greg Slocum <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants