jeessy2/ddns-go · error
请求失败: %v
Error message
请求失败: %v
What it means
Thrown by Eranet.request when client.Do(req) fails — the HTTP request to https://www.eranet.com could not be completed at the transport level. This wraps the net/http error (DNS failure, connection refused/reset, timeout, TLS error), affecting create, modify, and getRecordList.
Source
Thrown at dns/eranet.go:272
// 构造完整URL
baseURL := "https://www.eranet.com"
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 to https://www.eranet.com (curl -v) from the host running the program
- Check DNS resolution of www.eranet.com on that host
- Retry the request — this is often transient; consider adding backoff/retry in create/modify paths
- If behind a proxy, configure the proxy for the http.Client; if a timeout was configured, increase it
- Verify system time is correct — clock skew causes TLS handshake failures
Example fix
// before
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("请求失败: %v", err)
}
// after
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("请求失败: %w", err) // retry with backoff at caller
} Defensive patterns
Strategy: retry
Validate before calling
// preflight connectivity check
resp, err := http.Get("https://www.eranet.com")
if err != nil {
return fmt.Errorf("eranet unreachable, check network/DNS/proxy: %w", err)
}
resp.Body.Close() Type guard
var dnsErr *net.DNSError
if errors.As(err, &dnsErr) {
// DNS-level failure vs connection/timeout failure
} Try / catch
body, err := eranetClient.CreateRecord(params)
if err != nil {
if strings.Contains(err.Error(), "请求失败") {
return retryWithBackoff(3, func() error {
_, err = eranetClient.CreateRecord(params)
return err
})
}
return err
} Prevention
- Set a sane http.Client timeout (e.g. 10-30s) — not zero, not 1s
- Run the ddns client on a host with reliable egress; verify eranet.com isn't firewall-blocked
- Configure proxy env vars correctly if operating behind a corporate proxy
- Keep system clock synced (NTP) to avoid TLS failures
- Implement exponential backoff for transient network errors
When it happens
Trigger: Any Eranet API call where the network round-trip fails: DNS resolution failure for www.eranet.com, TCP connection refused/reset, request timeout via t.httpClient, TLS handshake failure, or no network connectivity.
Common situations: Running ddns-go behind a firewall/proxy that blocks eranet.com; intermittent ISP or DNS outages; overly aggressive httpClient timeout; corporate MITM proxies breaking TLS; transient network flaps during DNS updates.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
AI-assisted analysis of jeessy2/ddns-go@5874c2e666 (2026-09-03).
Data as JSON: /api/errors/f74f9b5d59fa186b.
Report an issue: GitHub.