AlexxIT/go2rtc · error
can't open two UDP ports
Error message
can't open two UDP ports
What it means
ListenUDPPair exhausted its retry loop trying to bind two adjacent UDP ports (port and port±1) for RTP/RTCP; at least one bind always failed. Typically caused by firewall restrictions or port exhaustion; no listener pair is returned.
Solutions
- Free the occupied UDP port range
- Use TCP interleaved transport instead of UDP
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at pkg/rtsp/client.go:455 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/719c887c0f4edc5f.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/rtsp/client.go:455
port2 = port1 - 1
} else {
port2 = port1 + 1
}
ln2, err := net.ListenUDP("udp", &net.UDPAddr{IP: nil, Port: port2})
if err != nil {
_ = ln1.Close()
continue
}
if port1 < port2 {
return ln1, ln2, nil
} else {
return ln2, ln1, nil
}
}
return nil, nil, fmt.Errorf("can't open two UDP ports")
}
View on GitHub (pinned to c245815e75)