Server locale: timeout dello stream a 30 minuti per i provider locali, nessun TCP keepalive (C)

- stream_idle_timeout predefinito 30 minuti per i provider su loopback, rete privata,
  localhost, .local e .lan (5 minuti per gli altri), sempre sovrascrivibile con
  stream_idle_timeout_ms; funzioni ModelProviderInfo::is_local_endpoint e is_local_base_url;
- client HTTP senza TCP keepalive: reqwest sonda dopo 15 s e chiude dopo 3 sonde senza
  risposta, e NetBird non fa passare le sonde: ogni risposta partita dopo 60 s veniva tagliata;
- test del timeout per locali e remoti.
Da 4e1f551b, solo le parti C (ordinamento strumenti, attesa MCP, eventi imeai restano fuori).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-17 12:53:28 +01:00
parent 8147e89f28
commit 832a749d76
3 changed files with 79 additions and 4 deletions

View File

@@ -370,7 +370,15 @@ impl HttpClientBuilder {
}
fn base_reqwest_builder(self) -> reqwest::ClientBuilder {
let mut builder = reqwest::Client::builder();
// No TCP keepalive: reqwest probes after 15 s of silence, 3 times every 15 s, and drops
// the connection when nobody answers. Some VPNs (NetBird towards the imeAI server) do
// not pass the probes, so every response that started after more than 60 s (a local
// model reading a long prompt) was cut and sent again from scratch. Dead streams are
// detected by the provider's idle timeout instead.
let mut builder = reqwest::Client::builder()
.tcp_keepalive(None)
.tcp_keepalive_interval(None)
.tcp_keepalive_retries(None);
#[cfg(windows)]
if let Some(path) = self.windows_proxy_pipe_path {
builder = builder.windows_named_pipe(path);