Fix pool DNS resolution: don't cache 0.0.0.0 when hostByName fails#801
Open
Gheop wants to merge 1 commit into
Open
Fix pool DNS resolution: don't cache 0.0.0.0 when hostByName fails#801Gheop wants to merge 1 commit into
Gheop wants to merge 1 commit into
Conversation
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.
Problem
checkPoolConnection()inmining.cppignores the return value ofWiFi.hostByName(). On the ESP32 Arduino core,hostByName()returns0and writes0.0.0.0into the result when resolution fails (WiFi just came up, transient DNS timeout, slow/lossy link…).Since the result is trusted unconditionally, a failed first resolution caches
0.0.0.0inserverIP. The miner then keeps callingclient.connect(0.0.0.0, port), which can never succeed: WiFi shows connected but the pool never sees the worker, and only a reboot recovers (and only if resolution happens to succeed on that boot).This matches several reports of miners that join WiFi but never show up on the pool: #169, #247, #706, #583.
Serial log of the failure:
Fix
hostByName()(and guard against0.0.0.0). On failure, keepserverIPat the unresolved sentinel (1.1.1.1) and return, so the next call retries a fresh resolution instead of caching a bad IP.client.connect(), resetserverIPto the sentinel so the next attempt re-resolves (also handles a pool IP change / stale entry) instead of re-resolving into the same variable and falling through.Minimal change, no effect on the happy path.
Testing
Built and flashed on a LilyGo T-Display-S3 (
env:NerdminerV2). A miner that previously stayed stuck on0.0.0.0after a failed boot-time resolution now recovers on its own and connects to the pool.