jeessy2/ddns-go · error
请求失败: %v
Error message
请求失败: %v
What it means
dns/tnethk.go request() wraps httpClient.Do(req) failures with "请求失败: %v" (request failed). The HTTP round trip itself could not complete for create, modify, or getRecordList — DNS resolution, TCP connect, TLS, or transport-level failure to reach www.tnet.hk.
Source
Thrown at dns/tnethk.go:272
// 构造完整URL
baseURL := "https://www.tnet.hk"
fullURL := baseURL + apiPath + "?" + queryString
// 创建HTTP请求
req, err := http.NewRequest(method, fullURL, nil)
if err != nil {
return nil, fmt.Errorf("创建请求失败: %v", err)
}
// 设置请求头
req.Header.Set("Accept", "application/json")
// 发送请求
client := t.httpClient
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("请求失败: %v", err)
}
defer resp.Body.Close()
// 读取响应
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("读取响应失败: %v", err)
}
// 检查HTTP状态码
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("API请求失败,状态码: %d, 响应: %s", resp.StatusCode, string(body))
}
return body, nil
}
View on GitHub (pinned to 5874c2e666)
Solutions
- Check basic connectivity: curl -v https://www.tnet.hk from the same host
- Verify DNS resolution of www.tnet.hk (try a public resolver like 1.1.1.1)
- Check proxy environment variables / firewall rules for outbound HTTPS
- If TLS-related, confirm the system clock and CA certificates are current, then retry
Example fix
// before
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("请求失败: %v", err)
}
// after (caller: retry with backoff on transport errors)
var body []byte
for i := 0; i < 3; i++ {
body, err = provider.getRecordList(domain)
if err == nil || !strings.Contains(err.Error(), "请求失败") {
break
}
time.Sleep(time.Duration(1<<i) * time.Second)
} Defensive patterns
Strategy: retry
Validate before calling
// preflight reachability probe
resp, err := http.Get("https://www.tnet.hk")
if err != nil {
return fmt.Errorf("tnet.hk unreachable: %w", err)
}
resp.Body.Close() Try / catch
if err != nil && strings.Contains(err.Error(), "请求失败") {
for i := 0; i < 3; i++ {
time.Sleep(time.Duration(1<<i) * time.Second)
if body, err = op(); err == nil {
break
}
}
} Prevention
- Ensure outbound HTTPS to www.tnet.hk is allowed by firewalls/proxies
- Keep system DNS working; pin a fallback resolver for DDNS hosts
- Keep the system clock synced to avoid TLS failures
- Run retries with exponential backoff for transient outages
When it happens
Trigger: Any Tnet.hk API call where client.Do returns an error: DNS lookup failure for www.tnet.hk, connection refused/timeout, TLS handshake failure, or the configured proxy being unreachable.
Common situations: No internet or DNS outage on the host; firewall blocking outbound 443 to www.tnet.hk; corporate proxy misconfigured; system clock skew breaking TLS; provider temporarily offline.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
AI-assisted analysis of jeessy2/ddns-go@5874c2e666 (2026-09-03).
Data as JSON: /api/errors/5adfe591eaef4fae.
Report an issue: GitHub.