fix(downloader): cap qB httpx keepalive to prevent stale-socket storms (#984)#1028
Merged
Merged
Conversation
#984) After ~1 hour of idle, the next renamer cycle would flood the log with "Server disconnected without sending a response" errors. This reproduces most often when AB sits behind a proxy (host-network Orbstack, local 127/8 proxy, remote qB) that silently reaps idle TCP sockets while httpx continues to reuse them from its connection pool. Apply the same httpx.Limits recipe used for the shared RSS client in #1018: - keepalive_expiry=30s so the pool drops idle sockets before a proxy / NAS does - max_keepalive_connections=5 / max_connections=10 so parallel renamer calls can't flood the fronting proxy Closes #984
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After roughly an hour of idle, the renamer cycle would flood the log with hundreds of `Server disconnected without sending a response` errors — most commonly reported by users with a proxy between AB and qBittorrent (Orbstack host-network, local 127/8 SOCKS, reverse proxy, NAS). The proxy silently reaps idle TCP sockets while the shared httpx connection pool keeps reusing them.
Same failure pattern as the RSS side, which was fixed in #1018 with `httpx.Limits(keepalive_expiry=...)`. Applying the same recipe to `QbDownloader`.
Change
`backend/src/module/downloader/client/qb_downloader.py`
```python
limits = httpx.Limits(
max_keepalive_connections=5,
max_connections=10,
keepalive_expiry=30.0,
)
self._client = httpx.AsyncClient(timeout=timeout, limits=limits, verify=False)
```
Test plan
Risk
Low. Behaviour change is limited to the pool's keepalive / concurrency ceiling. qB runs on loopback / LAN for most users, so a 10-connection ceiling is more than enough (the renamer runs sequentially per torrent). Users with non-proxied direct qB connections see no visible change because the pool is cycled at 30s idle instead of indefinitely — the only cost is one extra TCP handshake on very sparse traffic.
Closes #984