fix: make DialTimeout configurable via config#557
Conversation
* feat: make NTP server configurable * refactor: remove hardcoded NTP default in favor of library default
There was a problem hiding this comment.
Code Review
This pull request makes the Telegram dial timeout configurable, replacing a previously hardcoded 10-second value. Feedback indicates that a separate hardcoded 30-second authentication timeout in the client pool may still restrict connections if the dial timeout is increased beyond that limit, suggesting that this value should also be made configurable to fully support the intended use case.
| NtpServer string `default:"" description:"NTP server address"` | ||
| Proxy string `default:"" description:"HTTP/SOCKS5 proxy URL"` | ||
| ReconnectTimeout time.Duration `default:"5m" description:"Client reconnection timeout"` | ||
| DialTimeout time.Duration `default:"10s" description:"Timeout for connecting to Telegram servers"` |
There was a problem hiding this comment.
While making DialTimeout configurable is a good step for supporting slow hardware, there is a hardcoded 30s timeout in internal/tgc/client_pool.go (line 169) that governs the overall authentication wait time. If a user increases DialTimeout to a value like 60s (as suggested in the PR description), the client creation will still be aborted by the pool after 30s. To fully support the intended use case, this authentication timeout should also be made configurable or at least be increased to match the DialTimeout.
There was a problem hiding this comment.
@gemini-code-assist, may i suggest simply making the authentication timeout proportional to DialTimeout (3x multiplier)
There was a problem hiding this comment.
That is a reasonable approach to ensure the authentication timeout scales appropriately with the dial timeout. Using a multiplier like 3x helps maintain a consistent ratio between the connection attempt and the subsequent authentication phase, which should prevent premature timeouts on slower networks while still enforcing a reasonable upper bound.
|
Forgive me but you're awfully quiet. Have you actually built and tested if this solves your issue with your raspberry pi? And FYI, since the authentication timeout is hardcoded at 30s, it means you probably don't need 60s for your RPI, but somewhere between 10s and 30s. Also, you don't need to close the PR and open a new one every time there's an issue. Just modify your branch and do a force update. You only create unnecessary noise. Tell your AI agent to get smarter or to GTFO. For this current PR, it looks like To fix this branch without opening a new PR, run these commands to drop the merge commit, rebase properly, and force update: 1. Checkout the branch: git checkout fix/configurable-dial-timeout-v22. Fetch the latest from the remote: git fetch origin3. Rebase onto main: git rebase origin/main4. Resolve conflicts (Only if the rebase pauses): git add . # or some/path/to/your/file some/path/to/your/other/file etc
git rebase --continue(If the rebase finishes immediately in Step 3 without an error, skip this step). 5. Force push to update THIS existing PR: git push --force-with-lease origin fix/configurable-dial-timeout-v2 |
Replace hardcoded 30s authentication timeout with 3x DialTimeout so users who increase DialTimeout for slow connections won't hit the auth timeout prematurely. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
972bbba to
1befa70
Compare
|
@iwconfig thanks a lot, sorry for that. And yes, this works on my undervolted Raspberry Pi 4. |
iwconfig
left a comment
There was a problem hiding this comment.
Please add dial-timeout to config.sample.toml as well
|
It works on my raspberry pi 3 occurring #509 |
Summary
Makes
DialTimeoutconfigurable while keeping the default at10s. Users on slower hardware (e.g. Raspberry Pi) can increase it via config to avoid MTProto handshake timeouts during DH key exchange.Changes
internal/config/config.go— addDialTimeoutfield withdefault:"10s"internal/tgc/tgc.go— useconfig.DialTimeoutinstead of hardcoded10 * time.Secondconfig.sample.yml— document the newdial-timeoutoptionConfig usage
Also configurable via
TELDRIVE_TG_DIAL_TIMEOUT=60sor--tg-dial-timeout 60s.Fixes #554
Ref #509