AlexxIT/go2rtc · error

RTSP wrong input

Error message

RTSP wrong input

What it means

handleTCPData received interleaved data that repeatedly failed the RTP size sanity check (size > 1500) for 10 consecutive attempts, concluding the TCP stream is not carrying valid RTP/RTSP interleaved framing. A safety heuristic against garbage input from the camera.

Solutions

  1. Reconnect the RTSP session to resynchronize
  2. Verify the peer is a well-behaved RTSP implementation
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/rtsp/conn.go:261 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/df2b3f9b7e11bb7a. Report an issue: GitHub.

Appendix: source

Thrown at pkg/rtsp/conn.go:261

				// TODO: better check maximum good channel ID
				if channel >= 20 {
					continue
				}

				buf4 = make([]byte, 2)
				if _, err = io.ReadFull(c.reader, buf4); err != nil {
					return err
				}

				// check if size good for RTP
				size = binary.BigEndian.Uint16(buf4)
				if size <= 1500 {
					break
				}

				// 10 tries to find good packet
				if i >= 10 {
					return fmt.Errorf("RTSP wrong input")
				}
			}
		}
	} else {
		// hope that the odd channels are always RTCP
		channel = buf4[1]

		// get data size
		size = binary.BigEndian.Uint16(buf4[2:])

		// skip 4 bytes from c.reader.Peek
		if _, err = c.reader.Discard(4); err != nil {
			return err
		}
	}

	// init memory for data
	buf := make([]byte, size)

View on GitHub (pinned to c245815e75)