fatedier/frp · warning
wait detect message canceled
Error message
wait detect message canceled
What it means
MakeHole aborted because the parent context was canceled while waiting for detect messages across the multiple listen sockets. This is a caller-initiated cancellation (shutdown, visit canceled, upper-layer deadline), not a network failure itself.
Source
Thrown at pkg/nathole/nathole.go:286
if err != nil {
lConn.Close()
return
}
select {
case resultCh <- result{lConn: lConn, raddr: addr}:
default:
lConn.Close()
}
}(conn)
}
select {
case result := <-resultCh:
return result.lConn, result.raddr, nil
case <-time.After(timeout):
return nil, nil, fmt.Errorf("wait detect message timeout")
case <-ctx.Done():
return nil, nil, fmt.Errorf("wait detect message canceled")
}
}
func waitDetectMessage(
ctx context.Context, conn *net.UDPConn, sid string, key []byte,
timeout time.Duration, role string,
) (*net.UDPAddr, error) {
xl := xlog.FromContextSafe(ctx)
for {
buf := pool.GetBuf(1024)
_ = conn.SetReadDeadline(time.Now().Add(timeout))
n, raddr, err := conn.ReadFromUDP(buf)
_ = conn.SetReadDeadline(time.Time{})
if err != nil {
pool.PutBuf(buf)
return nil, err
}
xl.Debugf("get udp message local %s, from %s", conn.LocalAddr(), raddr)View on GitHub (pinned to 6c8a8d0a97)
Solutions
- No defect: treat as a clean cancel; ensure the caller distinguishes ctx.Err() from real punch failures
- If premature, lengthen or remove the parent deadline so it exceeds DetectBehavior.ReadTimeoutMs
- Avoid stopping frpc or closing the visitor while P2P setup is in flight if the connection is wanted
Defensive patterns
Strategy: try-catch
Try / catch
if ctx.Err() != nil {
// cancellation, not a punch failure — do not count toward retry budgets
return ctx.Err()
} Prevention
- Check ctx.Err() first when MakeHole returns an error to separate shutdown from failure
- Keep parent deadlines longer than the nathole detect timeout
- Do not stop frpc mid-visit if P2P setup is expected to finish
When it happens
Trigger: The ctx passed into MakeHole is canceled while the select over resultCh/time.After is blocked — e.g. frpc shuts down, the visitor proxy is closed, or a parent timeout fires first.
Common situations: User cancels the visit or stops frpc during hole punching; a wrapping context deadline (shorter than the detect timeout) expires; graceful shutdown racing an in-flight P2P connection setup.
Related errors
- natHoleRespMsg get error info: %s
- natHoleRespMsg get empty candidate addresses
- wait detect message error: %v
- wait detect message timeout
- open tunnel timeout
AI-assisted analysis of fatedier/frp@6c8a8d0a97 (2026-08-15).
Data as JSON: /api/errors/7874520918ff7023.
Report an issue: GitHub.