AlexxIT/go2rtc · error
wrong media
Error message
wrong media: %v
What it means
SetupMedia could not build a Transport header for the requested media: for TCP mode the media was not found among the session's negotiated Medias (so no interleaved channel pair could be assigned). Returns no channel; the media must match one from DESCRIBE.
Solutions
- Run Describe first so Medias is populated, and pass one of its tracks
- Re-fetch the session description if the media list is stale after reconnect
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pkg/rtsp/client.go:282 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/016e6fe17ebe8f6c.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/rtsp/client.go:282
port := conn1.LocalAddr().(*net.UDPAddr).Port
transport = fmt.Sprintf("RTP/AVP;unicast;client_port=%d-%d", port, port+1)
} else {
// try to use media position as channel number
for i, m := range c.Medias {
if m.Equal(media) {
transport = fmt.Sprintf(
// i - RTP (data channel)
// i+1 - RTCP (control channel)
"RTP/AVP/TCP;unicast;interleaved=%d-%d", i*2, i*2+1,
)
break
}
}
}
if transport == "" {
return 0, fmt.Errorf("wrong media: %v", media)
}
rawURL := media.ID // control
if !strings.Contains(rawURL, "://") {
rawURL = c.URL.String()
// prefix check for https://github.com/AlexxIT/go2rtc/issues/1236
if !strings.HasSuffix(rawURL, "/") && !strings.HasPrefix(media.ID, "/") {
rawURL += "/"
}
rawURL += media.ID
}
trackURL, err := urlParse(rawURL)
if err != nil {
return 0, err
}
req := &tcp.Request{
Method: MethodSetup,View on GitHub (pinned to c245815e75)