tdns hacks: use a default timeout of 30 sec for dns requests - electrum - Electrum Bitcoin wallet (HTM) git clone https://git.parazyd.org/electrum (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules --- (DIR) commit 731756f6e86a009dc3bd85dc72c5d5a8e897637a (DIR) parent f83d2d9fee160e7b5475d397672559fc8f947470 (HTM) Author: SomberNight <somber.night@protonmail.com> Date: Tue, 22 Dec 2020 10:48:10 +0100 dns hacks: use a default timeout of 30 sec for dns requests dnspython changed the overall timeout for a request from 30 sec to 5 sec in version 2.0 (see https://github.com/rthalley/dnspython/commit/7ed1648b8427e77b1f21d1896ca8aaff11598e74 ) 5 seconds is not enough in some network conditions... We manually set the timeout back to 30 sec. Note that in case these dns hacks are applied, and the timeout is reached, we fallback to the system dns resolver, which hopefully can get a response. ----- log was full of: I | dns_hacks | dnspython failed to resolve dns (AAAA) for 'electrum.org' with error: Timeout('The DNS operation timed out after 5.000827789306641 seconds') I | dns_hacks | dnspython failed to resolve dns (A) for 'electrum.org' with error: Timeout('The DNS operation timed out after 5.000998020172119 seconds') I | dns_hacks | dnspython failed to resolve dns (AAAA) for 'electrum.hsmiths.com' with error: Timeout('The DNS operation timed out after 5.000227451324463 seconds') I | dns_hacks | dnspython failed to resolve dns (A) for 'electrum.hsmiths.com' with error: Timeout('The DNS operation timed out after 5.000523328781128 seconds') ... Diffstat: M electrum/dns_hacks.py | 2 ++ 1 file changed, 2 insertions(+), 0 deletions(-) --- (DIR) diff --git a/electrum/dns_hacks.py b/electrum/dns_hacks.py t@@ -47,6 +47,8 @@ def _prepare_windows_dns_hack(): resolver = dns.resolver.get_default_resolver() if resolver.cache is None: resolver.cache = dns.resolver.Cache() + # ensure overall timeout for requests is long enough + resolver.lifetime = max(resolver.lifetime or 1, 30.0) # prepare threads global _dns_threads_executor if _dns_threads_executor is None: